{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy import *\n",
    "init_printing()\n",
    "from IPython.display import display\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "from tabulate import tabulate"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Equation for Neuron Paper\n",
    "\n",
    "      A dendritic segment can robustly classify a pattern by subsampling a small number of cells from a larger population.  Assuming a random distribution of patterns, the exact probability of a false match is given by the following equation:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAAA8CAYAAAC+ej5cAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAJ8UlEQVR4Ae2bi3UUNxSGsY8L4FFBTAeGVBDowEAFQAdwUgEn6cCkggQ6ACow0AF0ENgOnP+TJaGZ1XNGsx6HvedoV4+r+9ZjpJmDi4uLG9cBDg4OTiXnRvK+L8kr3D+E97KEl2pv4ZWi0aO+Ro/DHoyWpmEN+rDGeVaWv9Xn3RS5JvCawqa2T1GPgykjkMiQBP8qbZS+icbbWola8cTrpvp8EI974745OdT2TPg31e/Pcb9UOcbL0oH3J6WPSg9s/7ui/dzmZ/3N0kNC3GhJkvRM6QF9BCdKb1r6t+KKPiPp2bif6opyCOeLEk6s0lG4W7xURyDgtO/kHS1bPnblqf+iM0uPKsVC4cQQJYlGF+HNNEJ6ubx4HCt9j+GoviiHcF4oVQWY8LZ42TpmAOh8CeVQmQiuDo6wb5gXjVl6NBtfDBl1RCMK8D87CkOFwrxoE51sSLbkVH1RDuFg/CpDCy/H643aXzg5lDcj0pX5FyAPziilgb1sv6w9hZPUY8swoVDjvAgRpSbqbJ6R6BUb488tizaWMdN1SMvyrpJDuGa2CPvH8ile4Aow8Inrp7x3dljv2mv/1bfansKN6nGohhYguu7TQUJ+1R9b+uK2Hvx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E0dxGZQLk9a4ecOPq/qiVHO8lD2sVozBqdKsDz7CccaIPr9NzP5qyE7TQeXcgYcxhtjhylNbtuEu0GM3hZSjlK/1Ixunq/iUPxu7yUafo4GCODTmF8RcES+f9FGoFeKCoY7p7Y6NP1e2gvqwFnPKHVzXUrQ1wINdnMWDkvZcO4YlKbn3jCu6t8BnVOwN3Fso1CdOCmeJwovIo8Fx5lKwxvr/VFj73bONpCRqpqUdNuwecI/2YSpkZxrcPODZ8GwEbjXUKhUbnED9sWyzvHAhj5nYXPfybHZrqphyzmYCQYdwZqAkADLaYJtMJP1VXDvO9AyU30yEQBhw28jNTYCu+H8HZubURWsuABIEw65+/2FSeUTf4hBi82qS+EPXrqaW32pejJN8pMob6qYxNih91gqM06WPSkN/UvHmpSRGEwf3LOioj/FMRfat88xSaoMcLP2FEi8V6QDLjRNY4M02qzCzC5Sw7UI7GcBS70MFHncJjlpn8Man6zgLnQP9GlQRiOmDrP3k+F42QHgFAhPopapbE+84DCzgHnqiWtQ7D35GxWZAng41eFwDne+dNNmWx43/6+s6lVoV7wAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle \\sum_{b=\\theta}^{s} \\frac{{\\binom{s}{b}} {\\binom{n - s}{a - b}}}{{\\binom{n}{a}}}$"
      ],
      "text/plain": [
       "  s               \n",
       "______            \n",
       "╲                 \n",
       " ╲     ⎛s⎞ ⎛n - s⎞\n",
       "  ╲    ⎜ ⎟⋅⎜     ⎟\n",
       "   ╲   ⎝b⎠ ⎝a - b⎠\n",
       "    ╲  ───────────\n",
       "    ╱      ⎛n⎞    \n",
       "   ╱       ⎜ ⎟    \n",
       "  ╱        ⎝a⎠    \n",
       " ╱                \n",
       "╱                 \n",
       "‾‾‾‾‾‾            \n",
       "b = θ             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIQAAAA6CAYAAABxhPGiAAAACXBIWXMAAA7EAAAOxAGVK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uPDCQpLtaIzPV4b/0Q7hrP6hENG5cvA/LrZB3gpn4n4AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle \\frac{\\sum_{b=\\theta}^{s} {\\binom{s}{b}} {\\binom{n - s}{a - b}}}{{\\binom{n}{a}}}$"
      ],
      "text/plain": [
       "  s              \n",
       " ____            \n",
       " ╲               \n",
       "  ╲   ⎛s⎞ ⎛n - s⎞\n",
       "   ╲  ⎜ ⎟⋅⎜     ⎟\n",
       "   ╱  ⎝b⎠ ⎝a - b⎠\n",
       "  ╱              \n",
       " ╱               \n",
       " ‾‾‾‾            \n",
       "b = θ            \n",
       "─────────────────\n",
       "       ⎛n⎞       \n",
       "       ⎜ ⎟       \n",
       "       ⎝a⎠       "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "oxp = Symbol(\"Omega_x'\")\n",
    "b = Symbol(\"b\")\n",
    "n = Symbol(\"n\")\n",
    "theta = Symbol(\"theta\")\n",
    "s = Symbol(\"s\")\n",
    "a = Symbol(\"a\")\n",
    "\n",
    "subsampledOmega = (binomial(s, b) * binomial(n - s, a - b)) / binomial(n, a)\n",
    "subsampledFpF = Sum(subsampledOmega, (b, theta, s))\n",
    "subsampledOmegaSlow = (binomial(s, b) * binomial(n - s, a - b)) \n",
    "subsampledFpFSlow = Sum(subsampledOmegaSlow, (b, theta, s))/ binomial(n, a)\n",
    "\n",
    "display(subsampledFpF)\n",
    "display(subsampledFpFSlow)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "where n refers to the size of the population of cells, a is the number of active cells at any instance in time, s is the number of actual synapses on a dendritic segment, and θ is the threshold for NMDA spikes. Following   (Ahmad & Hawkins, 2015), the numerator counts the number of possible ways θ or more cells can match a fixed set of s synapses. The denominator counts the number of ways a cells out of n can be active. \n",
    "    \n",
    "## Example usage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'n=10000, a=64, s=24, theta=12'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAAwAAAASCAYAAABvqT8MAAAABHNCSVQICAgIfAhkiAAAANtJREFU\nKJHN0r0uhEEUxvGf9VWItTYahSgQPYV2SxfBBbiAbfSidSE60e4trASNjghZGiHbEFnFzpscb84W\nOqd5cp6Z/5nJzMMfa6rWb+MU9xhhBV0MMngJjzgI3jFuMJcBJ3jBTPDa+MJRBtzhIvGv0auaRtFF\nbOEhAZ6wWwfWi74nwBBNzEegWfRzAgCtCHwXHSXAbNHpCLwmG6taKPoRgUGZvjwBeKsDQ/SxlgCb\nuKqaRli4xJ7fcdkoQ86zu66Wow+Dd4ZbIRoxBs/oGEdkx/gz29iXP/d/qR8UhCWn2ReXCwAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(\"n=10000, a=64, s=24, theta=12\", subsampledFpF.subs(s,24).subs(n, 10000).subs(a, 64).subs(theta, 12).evalf())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'n=10000, a=300, s=24, theta=12'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANQAAAAXCAYAAABzomECAAAABHNCSVQICAgIfAhkiAAABwtJREFU\neJztmn+IVUUUxz/rjzZ33TXLTMXQXTUVtFzxV1pbWQSSf5goEm5pFJqUkKVl9sv8lSmoWWpY1EvF\nFNOEFDJJw6DSMistrcQyzewH2k/dUnf748yw82Zn3pv7vLsa3C9cePfMuXPOfO89M2fOPEiQIEFs\naHiuHUiQ4DxFEbAS+BD43ZCXq6sP8ADwB3Cg3r1LkOB/hLuBqUA10N5q+xUYpX4PB04gwZcgQYIs\ncAVUN6BQ/R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L/ODZA9zgVeQCWIzcLWnvzj5i2I3BC2R\niXsPNbz9onwYaemG8JIgQYIECRIkSJAgQYIECc4j/Acco7yxYDRtqQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "8.37584522709849e-13"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(\"n=10000, a=300, s=24, theta=12\", subsampledFpFSlow.subs(theta, 12).subs(s, 24).subs(n, 10000).subs(a, 300).evalf())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'n=2000, a=40, s=20, theta=10'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABNUAAAASCAYAAAB8dOgNAAAABHNCSVQICAgIfAhkiAAAEItJREFU\neJztnXvMHkUVxn8ft1IKBYFiiyV8yM0bSgm3cIsiXohGDDECCUK9IiByEYJcrSCIJCigBET/eBVU\nFA01QiIasWLCTQMqKKFIEIEEKAEFsRR68Y/ZtdPp7O4zu2f6fiTzJM3Xd/fZPTPnnHnm7Lv7zkJB\nQUFBQUFBQUFBQUFBQUFBQUFBEiaCz7sCXwUeA1YBWwNnAE8L51KPLbzCK7zhvL2BLwLTgbnAPcD5\nwJO043Rgw8pGjUOBa4A/A0uBZcBKb/8fgKuC82wC3AW8vcHOG4EvAS8DK4AZwJnAUz37sS9wXNW+\n6ZX9i6s29+Gpflb7ESLm5xztmwucVXGmVee7BLg/0qZdgAWsjvHS6vOLHuch4ELgt8BLwJ64+JwE\nPNjDrhpflWcdtxT/+WiKL2h+VvqROi4VuyrPOg9qdOmG5flS/KfaVfNKGecp7UvRISW+1npqrWvj\n4lnGN4VnrX+g6wF0j0vLeiOFp/oP7HQX7PVA1dMaXfHoe63W5GelvznmI9XP1nWxdd2p9jdHXeej\nKb7W/lPyuc91RVc/VJ513a7GIyVfoHucW+Zfjuu8EEPrYmvdtdbnpPhu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zjgBaHrs\n94xq/ydbzlHjhoq7SWTfucA/cI8IgxOop4H9Ap7aj4uBk1izKLgOtxbEHj14qp/VfoRo8rN1+46o\ntk1622biJgn/rT7rAXfiJpQaH8XdIfKP3Qv4KatjOgF8H7cQp1/IqXbV+Ko867ip/QjRFF/Vz2o/\nanSNS9XuuPLAR5tuWJ+vRpf/VLtqXqnjXG2faleNr7WeWuvauHjW8VV51vqn5oGPtnGUq97o4qn+\ns9Zdaz1Q9dRHWzxS548aTX5O1V2r+Ui1a10XW9ed48q/EE3xtfZfaj6nXFe09UPlWdftajxS531o\nH+fW+VfD6jovxNC62Fp3rfVZioe/E9zrUS8CFuO+HdwSOJk134qwK+43qD/DLXaXcmzhFV7hDec9\nj3tUNoavsPbdopnAz3Fjdw7ukdv7cG9eWejxPoy7M3EI8MfIubfBicgbgLdW254FHsC9VvgH1bbp\nuLtdW1d92Bz3KPmdwflS+jEf95rl5TiRfK7avzg4TuUpflb7UUPxs2X7wN3kOK2ytQr3CPJVuLfr\n+NgSt1jnDNwdlwncpPNIwDsQ9xr1pVV/7q/aEa6VodhV45uSB9ZxU/0HWnxVP6vxhe5xmWJ3HHmg\n6kaO84HmP8VuSl7NRxvnSvtS7KrxVdtnzZvK82qO+Co8a/0DLQ/UcZSr3rCcL61111oPFD1N0bWU\n+UPxc8o8aDkfqXYt6+Icdec48q+GEl/r6wq1PgAtX9R+KLwcdbsaj/l050vKOFfOB3r+gd11Xg3L\nuthSd631GdLquoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKC\ngoKCgoKCgoKCgvHjfy2Q6kx6SVXkAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "0.0000000000000000000000247192330943086582209846076658181789379633300009332061\n",
       "2443608951048768022360840257449483136714689953"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(\"n=2000, a=40, s=20, theta=10\", subsampledFpF.subs(theta, 15).subs(s, 20).subs(n, 2000).subs(a, 40).evalf(100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Table 1B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n=100000, a=2000, theta=s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'s=6'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANMAAAAXCAYAAACRfnp7AAAABHNCSVQICAgIfAhkiAAABzhJREFU\neJztmmlsFVUUgL8HraV0YSvSIgplEVBRICwGtHHBGCI/DDECERGXCKgoKkQkghUoIiaIClaRGBVU\nIos1YCISWTQRRAUVFAE3pEZEIm4oiFB/nDt59913Z96deW394XzJy5s598w5s5x77zl3BmJiYmJi\nYhqQImAlcFbItpiYGI1bgEqgDugUoi0mJsaHoA6T1takgU8mJuZ/Q45FdjYyjf0FHFf/lcDvGWxd\nCIxT+vlAc2AO8ImhtweYBWwEjgL9gKnARGB3BHvdgYeB/choUQJMAX409DoA9yudPGVvLrAzgt5Q\n4Gl1Lt59OqW1fwAsUtsD1PXlK9vbgBnA94bfzsCDwDHgJFAA3AccJJjJQK66BzaaA1uB833aw/rN\nZA+ix1AQmfy6xkGjcQ7wHTBI7ZcC3yA3Iog+wFqgmSarBn4Dehu6dcbvb+D2iPZaALXAaE02DdgF\nnKbJ2gA1QJkmK0c6drcIevdarkP/DVV6fYG3gJZqvxB4BzhEaopQDhwGhmuy0UhntQ14Hh2RAanS\np70/0rHrfNrD+s1kD6LHUBCZ/LrGwURgQcBvlGE3VJqnk4MEzSRNdibwE3CX30GKx5TxEZpsmJI9\nYejuBxYDrwHzgJ5Z2KtCAlN/8K2BE8AETTYFuZEm04BHIuhVI/cml9RUeTCwUNt/A+hq2OqjrmO5\nJqsBfjZs5SOzxVjL+XgsVrYqDXlP5ft5Z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zkyu9o4qPb3+8ugKfKy22yJLtfsses8gL4KbhdDT\nGYA8zMNpR6QyC6klZmiyMRmOaYt8MbFC7Q9Bgq5G+3mz6Ei1P5zsMf2GIWoMfYHUZ7dF8OkaB43K\nKKR20fPdBPAL8Kqh203Ta4a8r9iHvCjz6IeMJO9rshWk5+HeS8zpEezNRD7L0dORLkrP+6oigSxF\nX0Q6RcismBdCT+cG5SvoxeCN2GckffVvEjIyd9Bkk5VPswPrdCK7mSmK3yB7YWIoLEF+XeKgUWmC\nLFtP1mTXIqNJJ01WgUyr6zTZHOTLAf1iliKrOH01WX+k5vFebCaAF4H3SA1UV3tlyIO6XpMtAD4j\ntUgfoWT6dRQjnfuaCHoeU5AHdrOlDeAyZNZaZvyWA69oeg8A35Jc0eyDrHDqK342uin/QWmmV4Q3\nt7RF8RtkzzWGohDk1zUOGhSzwGyNFKIFyOyQQG74V5pOd6T2WUXqtDwWuBJ5sVqKfKYyHVkt0rkY\nuBMpcIuRF5tVpNZMYez1VsfvRWaQ1sinKwcMvQrkS4bjyENpirzo2xRRD+BqZMQcghTtJkfw/xpg\nNsnZOB8ZXUvUNbRAUsItPscWA68jz6JMnesO5JOnGiRlWgqcQXJJ+jCyOLAEeCmkX1d74BZDroTx\n6xoHMTExMTExMTExMTExMf8B/wJJdJKmb20gKwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "6.35308872941916e-11"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'s=8'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANQAAAAXCAYAAABzomECAAAABHNCSVQICAgIfAhkiAAAB2VJREFU\neJztm3uwV1MUxz+/Xlfv0tvcuCoqr6mUR5Ew/ojGmMZIUyJMMkSoEeNxqYhGkogYfmRShAaNRyNh\nhkSekTAoVx4Zecur64/vPnP33Xef89vnd28/NOc785u5Z5111lpn77XXXmvtcyFDhgw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u0KdPgXdSb7o06l27kL1TvKvFuFRWuDAtDJMe8ECoDV1E11\nQ+1rhI4xpli0U9CXEhX4ETUEWsTcT4skeWn9oCTYRvy3btMtvt5o0N1890g0sfejtGI6daNwqI5Q\neaD28ApUnN+Ntv7uHj7Qoej3aDfxIY19ZyBnX4RSrKXUPXdrjs7Q7kUBYiVweD31DkXjsRQ52cPE\nf0/WBqU8W6jp1L2CxiGNfaDdOG/0LTbv3tPh6YwC7XrL/q3GhjExcpOQRl4aP8iQIUOGDBkyZMiQ\nIUOGDP8B/ANpTKA9rINquQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "2.52507239284961e-14"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'s=10'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANQAAAAXCAYAAABzomECAAAABHNCSVQICAgIfAhkiAAABixJREFU\neJztmnmIV1UUxz/jNuaWW6OW1gzjkoGhlgtpkkaLJBQRmS1mG9G0W1JpiyG5IKSJNRVBU5oLikUl\ntEBJUJlBmtouDJVlOpWmTTWa2R/f+5g7b+7vN/e+3/tJxvvA483v3PPuOXN/57577rk/yMjIyMjI\nKDKdgbXAyTH5TmBf7Ko+uq5lZBxb3AjMBo4A5Za8NzAdqAQqTFs10OOoepeRcYwSn1B9aDp5rgTO\nsh9oVXyfMjL+N+wCfjF/nwQMBD6wFdrkeLADsBE4PcDYIGAe8C2a2T2BGcDuhHohvgxES/SfQIO5\nzwYOWDqjgZtN23Gm37nAp7G+RgL3G52+wCbgYeCHIvvn099E4Gnjc9TXP1b7x8CT5u++wANojEtN\nv/OBbQX8Hz56vuMcSkt2Q+OqUOaYq0VGoC/mSEDnx6PN2tWWbCawHWiXQC/El9OA72hcensDtShg\nI4YBrwPtLVk1sB8YasmGA28BXc3nTsB7wB6aLv1p++fb3z2mLdc10ej1AF5BKUpEBfAVMCDh/+Gj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GhKpHG+x+jrb+NA6or14IG3GnEtEm\ntA7l2JvR/qHS0olShRKapwRzgC9QYEZMLZJ/SRiJgsVVyj8B7RlcwfkM2ry3d7QVSpJxjvgS7TWr\nEtgtRlwlJumEGkDTMvJ6tKyXWLJK9E+uTaDny0pU5bF9KUFvyldRynEQFV9qabpaRG/pTWhPE3Ed\nKkLEKzlji+RfEqLD578cbXXorT3C0dYJva0/T2g3H6HjnCZpx1XqrELLaAdH2zgUcG9asj5oab3G\nki1GVax2CfR8fWkFfAjca8kuR0FVbsnmol8O2AO+DAXXcEs2Ab31l8euVeQ+R0nDP9/+ImYYnRty\ntE9GY2rb6IKqfq6qoK/dlvR8xzkJ+ewmiauiU4YmyXYafxtWB7yLDroiBqE34FOx54eiN8UiVCZd\nh3sZ9tHz9QW0D6lBwbICBX4lzZlm2pahg8fV6EerNnste/HLXrHS9i+kP9Ch7T7gTEdbxDj0e77V\nKBjXoJJ9Ersh/k2j5XH2JcSub/xlZGRkZGRkZGRkZGRk/Ef4Fz13HefnOpapAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "1.00163216178113e-17"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "T1B = subsampledFpFSlow.subs(n, 100000).subs(a, 2000).subs(theta,s).evalf()\n",
    "print(\"n=100000, a=2000, theta=s\")\n",
    "display(\"s=6\",T1B.subs(s,6).evalf())\n",
    "display(\"s=8\",T1B.subs(s,8).evalf())\n",
    "display(\"s=10\",T1B.subs(s,10).evalf())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Table 1C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n=10000, a=300, s=2*theta\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'theta=6'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSU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W9NsBbtbez0\nrxM6CFkW2iJP9DUKgpdkBcB7wGekR9+ByLnrLdkt6NRksfNbigwe8BzwI5UnOL3RjeqeEM1Eb+Zt\nIyxCN24fSzYc+Ib0TxwaAR+i74YCaqEj2Kct2TC0UOy2vv35js9Xr6/9AiagqPtQSBn4+zLf8/D1\nby4Em3r3JS4oPTwB3GfJ5iNf1gmpXy3cjdlNwOPosd0IvXSbQXpE64py5uXAo0Z2nOi3xXbKUQ/l\n6y3Q5qwx+ihxa0i7UcDtKIqVos8zJqPTGZuB6I39aWTUQvSiq8yp1wxtTkvQm+sC5OTvc+zPd3w+\nen3tF3AXityD0CY7DB9f5nsecfzrQyu0iC+j8mj7GDqUeAd9fRzQC81vr9HdDH3iczBH3QkJCQkJ\nCQkJCQkJCf9L/gVg3bhEI+eOKQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "5.29386836275369e-8"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'theta=8'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANQAAAAXCAYAAABzomECAAAABHNCSVQICAgIfAhkiAAABnhJREFU\neJztmn2IVUUUwH9ra5u6rn2ImVhpahpouZEZWlLaB6J/iP9UKFYQmZWZlWBCYallClmmbaXVLaWM\nzAQVtAUN+8NQLEr7MKJaMc0s7MPKzLQ/zgxv3ryZ9+bed++mcX/w2L0z584598zHPXPmQk5OTk5O\nTsZ0BFYC51nllwELgVuAJUDvVrYrJ+ek43ZgJnAc6GGUnwq0AOeo60HAttY0LCfnZMaeUNcBnxrX\nNcAhoKcuaNMqZuXk/D/oAfxkXB8HDgL9dUGtdcPlwHSgHdAd2Ao8AnwXoKw78JBSUge0B+YCOzzy\n7YEPgIsddSOB54GPgT+Bv4BjRv02YHGVNj8ItAWesMp3AbOATcDvSMw8HZgMfG7IheoN9csVwET1\nvO2U3OPKByYhetP2X2v0RyXKj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nBpkE/1YDPmi02KDO5EHcqWeIypPqLbICjcnwAafzV2BZx3l\nrk7YDLzvkN2DpEfj6I3jl36UJikalMwxJJkSqtckDf9l2Z6mH5L2fq6MTIR7vHRAfPSMo24j0gf/\nKbORTbnJhDLyXfBv/GqQLEujoy6i8oQaqmSmVpArZ/N4ZOVbbfzWqXa/UNdjlexvwEeO9g8jh7Fx\n9Ib6pQH5+uAohYQJyEDR+65OMfSapOG/LNuLQ4R/vGxHEhA2u6k+GRILe79wGzLbZ1nlV1rXfZBP\nSwAOIJv2QY7265FBGhpz2+hDQtfbQVPJ5uXI+c4Y46e/fFihrnVnrAeutdppRCbF8ph6Q/1yBNkz\nfUPxaqrfXlspTv2G9hGk478s20uLdcheqsYo64Ukl3whcyaYJ8vDkTTxeooHTy3FK8Mw5KymGbhB\n1U1BcvOjgG+VXAPwEnAfcjZhoz+zaU/p91EafUB4xFMfarNNW+uvZh7yHBOUTTXIarxF1cXRG8cv\n85FEhTmhpiDhlXnSH/d50/ZfVv0RQrnx0gTci0Qjy1TZZGTBWlKl3sQcxP+tlrna9EVWXjveHYaE\nT28iK/9bwNWWTBfksG2n0fYB5LU8zmHTGOBn5APVamzWNChde5XMYWSyjDFkrlK2v6aeZxbF39jF\n1RviF4BbgTeQAdGs5O3zr7jPm7b/0m6vEnHGy0DkTbUAObxfRfHxR05OTk5OTk5OTk5OTs4Jxr9D\nk5FbQWZRewAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "2.81724528327272e-10"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'theta=10'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMoAAAAXCAYAAABKxdBZAAAABHNCSVQICAgIfAhkiAAABvRJREFU\neJztmmtsVUUQx38VankURKRQFBQQRESMNQKKWt9Goh8MiUQC8Z0AKhFEFDUiCETUxLeiQPQqKCX4\naBQStBEQP4D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ef38xxE6MrusjZRGNJsR59fDfa\n4uuPIpabd56B0p3nkBPNxH/HAZq0VcD3NFaQ1qJdJY4ubdEEPoMiTB3+29Sdlhz3cSMkRo9f0AeH\n2dAZ7VpLUd6+mMbPtOPKi6NfqJ2rTf8StKCXohJ2sfULQej8gq4TlqNixAKUdfjSsRQpUqRIkSJF\nihQpUqT43+A/rOBP1yg4VwIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "1.54192767258720e-12"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'theta=12'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANQAAAAXCAYAAABzomECAAAABHNCSVQICAgIfAhkiAAABxdJREFU\neJzt23vsHUUVwPHPD/qwL+TR2pZUKbQFQapUAbVo4+sf9B+sRqng20QQiahtQCJYKUSUBFBRFBWv\nSLBSxSZAIhJ5GaUBUUlRRIlarKDUiA/Qgo/6x9nNnbvde3+z97Y/xOw32fS3M2fnzJyzM3Pm7C0t\nLS0tLS27mVn4Bp5VKb8c/8J23IkXpJWTJqRrLS1PLd6FBXgdVlfqHijqxvDQBPerpeUpzQ4srJSt\nHfTAHrurJy0t/6dMw8l4E76E56SV1ZBvAT4kZuZUTMf52Jyh6D6sw814DEfiDJyKe4fUcbBYEf6B\nx4t/1+JvicxB+IiIaf+NGTgdvx+nv6sxGR/rUz8dm/DcPvWHFM9uKcYyG2vwhyHljhb2miZsdAfO\nxu8SmWPxOdyta5P/JPV34jPJfY79cv2Wa+eccQzDrvLHqGzG1XgCD+MaHKrXD2A/bMT8pOxAYfAl\nGYp2VK4ncMoIOg4T8ery4n4efq13yz0Qf8TKpOxE8cINOh8eIF6etX3qjxIv544+9U/H1kJXyZm4\nB1OGkHs+voO9i/uZuE04bGEi90E72zm9jk1kc+ynpo06v+XaOXccTdlV/jgVFw+4VlXarQv50vEu\nLGSeV9epNYXCKmfi430GkrI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n+7R3ayE3v6Yu5bf4bvH3PHy6RmbYCTVDLACfrKm7SYyxiVzKmEjYnDOgX8SkeVScCevItV+O3waR\n2jkldxwlzxZ9/uwAmY7R/DEhlNv9HJFi/WWNzOfxVzxtQDvLRAatymzdla6Jjk3Fs1WmihV224C+\nzBHpzQ3F/auEwzYmV7lLHl/cr5TPY/ix3nNHyWKRyWwil7JOnH3OTsreUiN3tHiR+qWic+2X47d+\nVO2ckjuOkp+Lc9h7xtFZxzB23u2MiZ+QvKSmbpZYsdIwYYne+HyDnePo8oPeWUPoWCXi+FTHmEgD\nX52UnSZWtgVJ2eqirUELwEKjfYc6R/yUJg11FhXypwwhB29Xv6JXs3jw1qKNfh8tc+2X4zea2bnJ\nOJrQMbo/JpQ34qd6P2TtJYz++qRshdhib0jKjhL/d6T8uDiGK/ADvRMxV8ceIp2b/nT+DWJlTZ/9\nMH6jm5FaJjJU42WUlghj9wuZ6B5op9fUzRcv55uTsovF2KYMIfcKsdtcWbnW42s1+tcUfXtnn77n\n2i/Xb7l2bjqOJuwKf0w4K0QI9HUxgA0i3ZpyiDBmNd59aSF/RdHGOvW7RI4O4oNip6i/SjhkUUVm\nmvh28mXxYtyIFw8Y317ie8iDupmw28XHZiLsuEEc6Mu0/rbimRMqbR0hQseL8EXxzaMu7MiReyTR\nV73W1bR5nHiBjhww1hz7kee3XDs3Hcd47A5/tLS0tLS0tLS0tLS0tPyP8F/Y8KmaifAEoQAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "8.58694100276592e-15"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "T1C = subsampledFpFSlow.subs(n, 100000).subs(a, 2000).subs(s,2*theta).evalf()\n",
    "print(\"n=10000, a=300, s=2*theta\")\n",
    "display(\"theta=6\",T1C.subs(theta,6).evalf())\n",
    "display(\"theta=8\",T1C.subs(theta,8).evalf())\n",
    "display(\"theta=10\",T1C.subs(theta,10).evalf())\n",
    "display(\"theta=12\",T1C.subs(theta,12).evalf())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Table 1D"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "n=100000, a=2000, s=2*m*theta\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'theta=10, m=2'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANkAAAATCAYAAAAdzaikAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAID0lEQVR4Ae2b+1EcORCHgSIAzEVwkIENGfgy8CMC2xngIgKXnYF9EfiRAVwEGDKADAxkwP0+rVolaSStZmY53x+jKq2kVqvfLWlmYPvh4WFrKYsFFgvMt8D29vaJqPyh+otWufUeqjv8LGWxwGKBeRZQgn0XBZdYSq5P6l942Nb2cpLNM+6yerEAFlBCcSV8pny68uM9tXeqT5aTDIssZbHADAsowQ788nsjo2Sz/tH/Nskk+FMT2FrB9iKFDLy0iwV+qwWUUDcSgKSyZONks/g92K1J55HeicC7Gk4O15rPEWxf/TdRRkdT7nhFCO6xHLGW9THOP6K3J4A7ftXSpzxbNeXfHrk9TpW353sqDu4BVi28v0vO8xJX4X/M4F+Fa3JnU6thTc6xvKHmabX0wfnmR3Rh/DHXR3SAu4d1tUeqt4xrugjf9MZOh6rQJOCSIrzuuEgWThisswUke+Ueyf6l8N+L9k+/DvtRbrdklGLV5LUqgVWcj+HCw3HgnxhcfZKIO+lBBHPBKhhGv1TlHrtn83ErOPSo4NDi0CJuYd1AbtaqEog9vD/HNOn7tS9iuGAEJbI9N7jHu7ZxrfXrSnL28u7SR3zAS2hq/FYVpYI+6qNLIo/G2By8oJ/pIxj+i9fDB1vk/gbWjAujObUV/S5bQF+lR25i96yjBl09beR4ofpclT4MD4oJpAleRWKcxOg1I4CnepfPC4agiYMNR3B4IEQxcQTv4m30aFW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oPqth0bumWey6jfP2uFCBgCZxSwOT41bE3aOIQ0bbEHUVb63gBwL2+9uHZ3nbNlrugENdCAiMUyfFDMnGquW9iaglSdLJkU3dQbCMYY99e3gNmNYDk5hQOz1QRHtdFTmYq+oSiNe6NsPRO/AkCftY8XTaSvBgs+Bt8ISV0tL4rLjwvaCHrrDJW7lnMssW7GhMEx1Kcq0FccA6nBnB29PheHuO1+uzm7IatYCytZ11p53E7pejxwoHg2KjcokmQxCdVkE08bzRPMNpujfNdIgWktGOB1mVfLf2g2ss75VQZeX3cKaA+bxjX+kF4XJUPhRsSQzCnJzbwrLhCl3Q324Rn5opo3XEhnmxumypz5Z4mh5RgdxpUUeMjZNcHYeHhGPAJEkdLfZzAB0+eW0r0Wx8N+fOc0hp4hI+dDZym3KLR4g2P5Eu+8YG3zaklyTWVyikYu3Ty8TbHYQyOaiKnh63lndPTunX6JHwi/skHbNFhYx3Y3tOPfctJN9BRMHSPP3CPjotct7FjL2uil9HQXJfchr+pdkeMa8Xt6vEkO6Nq6Y5MQuUnDwbnpcRVTKOz/1l87ErhlmhMIFHs+Wg1Gv4O5B6iNCHQHzyriD8OIsHdbq6WXZHX/flbx1eCuwd+ta1SkrOLd4toYY4bCJtDKJKZ4Ic//rlnQjB8yK0FHzv7+xZYwFOfnYWXPbeeDiDWQy/XfdNx4XhN/Rkh91QWxXWD/yfDsMLkOGdXoxBMBJd7w6R5nksGD8SCh2DTPAZn9xxcG4TnHKl5eIBH0JKIF8ZDfXO6XVG5hpDEvIxwQQFOXNbJDe4I3uh+qhpvHDV90Bs9KMj5QTJWN5Z1cmp+DO9eW3LqxpsTwZ/8gbD4cq2Ed6nwZjJ5PhY+OmMj95JD7bHqQHfhdcWF1s4q4tNriy65ZwmTLf4X4wNzygzZPj8AAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 4.91541864813209 \\cdot 10^{-9}$"
      ],
      "text/plain": [
       "4.91541864813209e-9"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'theta=10, m=4'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANkAAAATCAYAAAAdzaikAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIg0lEQVR4Ae2b7XEUORCGMUUAwEVwkAFwGUAGUERwJgMoIqC4DCCDO8gAMuAjA8gA2Ax8zyOrZWlGu6PZNVX+sV0lS6NudbdetT4XTs7Ozq4d6YjAEYHLQeDk5OQ1mn5kbRvm19uT4yS7HHCPWo4IMMG+gMLfzKmvlO9R/kL55PoRmiMCRwQORyDvYJ+dYGrL+SPLx51MFI50ROBABJhkv1DxhPSTdIf0kYm2Ib92ZXeyvN3qYyHqbpLswJEGERAv0qnYLTVBxiNOQ7Yj7Y3579DZOHgFPsQIN0xp5yL/SHpN/Sn59p0sg/OM2fhMwVGinRe/mv6NLdRK+A7YiyzwgNyZ/6KWkYecK4OOp+03l8mu3Y8Vwo+gJbvKIaO+lyQvpn+Q/H6HPkHZSrQz+Bax2CW3xjaygaF+3iW9xsfvUweRE8sYH/vit7KlP8g8pu4daRt5Ob8lE9m1mL+plN6m7H1kU9Wt1lm33adMHxwr+9uNE3UiM4SvsiOEPnH/RjJG3tqGOsdDPO96duwmmDYyALv8aT2yYehh8GyvnupbmUYn33bYJ87STnlI+yY/zJW7Gboip27RbiX7JsqR014fH8d3L4c/hMUuOXhDtpHz8lz8oexgaf9O7Vuub3RS58opXnV7cVOn/XRS1Em9tazfpiXMw6fn4RNtDG6DaurnkM7Qs0+OTf2J/tlX/Z/FirqhRXyRsS8fBlLpK7Iqn8awdafdCQTjOUlwmgmxCwBkdX466MnRaKc+0qzz1Dk4v0IugzFkm3aLdrM+A/C0tpHrHSBfgQ7CAh1bMdPuiO0sVxal8Il6J8qH+M5+a89BrCeJfbGu9IdyMyahg3oXp4bH9yjmjmMzXtknx3svneHXoTn2A5denDkOQ/iu9UO9pCa++E4T7zqF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Oluw0sXx6bh+UeaEBTX2DUQDIxC6H+PLe9l7qY+ihiAi1ggtxazRdvZF32LvlkOiroyRvjgzuHEmk4aj4se5UxOuprc6YqOmoG+UcxTM+w63s3YoSMWnWRjrc7aH8vaQIe67NNBlHWpI7Cs9UVdF5tacJ/yDRoZMH/RGbf6mhxEdw3rXfmnd6ZaVudmE6kSaJxHp4N9F51lkKhL7alT1p2vt/KkFR2ZCKwhu+gWRCePgdGQ9uAbjOoewgI5A3IIsxW2UZl+yujhmPqd+e629iet7pR9YZz1S2U15TbqDuxqtuVRzKft6m91lH+zdxk66ZuL4GWRj3CL+F6WsaKHTrhizBICnrkX72S2hVw1KbZ6qHNla3605NvJ27t3eJZ2IpDN+blen8qPspTX2LVt+YW+9lWd23iV3UUs0NHFLNcv2kbO3b3BK9sXx/ID8y6fsi1BTFhGP/lOWJF377/Uz8akslMwz3Uukva12KBs8GrXl8sUT5SHdUabQ3Nsdu9k2e9hfA/1o24/m1zBzIBNwXUFFchmwHMHDNQCKmVlHYhyCafsQKSHDnIDJ5K7ZfklnrJyTTDwLXjNwI7azXIGWbojRh9zvcCXfx5U86IM3z43WASvzrfJUT9sG1nxqTELHEvwahPS7+m/MDD4ZTb1WT54ZYwmvq/B3LHQz3qSOf6NXb6Hdda+HFLG5tZJlnEYwvcQH6ZtZ//VhWOFge+2744jucUaYOk3APg62X2sgOfdw6CQPOK8ol05nsA3yEOvMjV9RbbcwZB1gOKIqi6Pjz5abOpGlpfshjxy2n5JUldQ81teVJojvxOLkB2RG7WNnPjp44+s36f5Bsdcr39O3ni8sVrMnETlt0krJWTlif/Wn1SyzBrMVS3pcxfHNTqTpj3/YMeFWj+MXXOvEsbeJ/Aov18hN4wvbS+F/gezxyD0ELH3JwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 4.62568448037595 \\cdot 10^{-6}$"
      ],
      "text/plain": [
       "4.62568448037595e-6"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'theta=10, m=6'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMsAAAAPCAYAAABKgjuRAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAG2UlEQVRoBeWa63EVRxCFdV0KQOAIkDMQkAFkIMoRABmIIgIKMsAZ2CIDkQFIGYgMsJSBfL693VM9uzO7vWJd/KCr5s7r9HOeu3t3d3d3B78K7Xa7E/l7Ff1V25HqD9X+LbYvlcV3LMwzpX/Ee7uE37r/Z+vf2p+fKS8by11cLGJ6b0Z/V/6H0vs1kyjLvzUOmyXzRNm50uPe5BXmRv0sDl8wlKGKRzja3yoRh9+VqJ9L7mflAwlzqgL6enQr/IPYKZ6Pof5Q5ZctWzO4tfqTMtkAXpuN+EydOVD8tr4hk8zUfMnojnIpi4fxfC3dbk8FycgUJuWPcLmxlDEHJNGl0mmoE6xrpWNvm8uz/FviJGuYxMqZhNiPI0c9O9WHPyRw5Az2BK+2j2MZamNhxPjAi07a0R8TsiPWY3nmctXPZGDxlviqnMIhQ5TSn5VpuMpvtb1SQlnxJdi/OF9MJrGY9dtlxlw88LFBDfPT86xMw6X8ETYXS4wQEZRrN8hzE3Lh9V6e5d8aF+2R7DMlnJlMfsepbxJ87/NcGGLxyuueI1fpMtSrgQjt7GZVn+osqBvHeK62i4jN4uCPfC7P2iv9WZnCefzKwlAbPqOs+G06UvNFfCm/o/0mH1t6iyUlU/xr/KnGy+2RjCqWv6kBeqHkV5OhwX6+KH+mY4qgzVGWf2vcnE337eP6iZ1LxERvEdeW8dWBY771TETMmXhOWRz4rP6sTGy5tYR8dnTqLcqOY1Z30aG5xolb2VE694WszDX+pGLpi4UH1X9HRlH1YNE/R1n+rXFzNt23j8CxQVyMNgmO6vLMoYn0aaxAeDDvYnuQ0Yrvd7DCnGRxLjujf41Myfus9IDcdYifiQkVv/fV4cVGy58yX9boNpme/Skb/vJKzNfIXOOPsKmxPAwGRLv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otwq/1x30xvy56UzBl+/Kz8CTrnYxmAXDHGX28RHAeTFYuiyQJS2yK/De6muGD/0mJhclYTWnV4xpOYgLErlclhdjNByt82gl4Gj5g0F6Pxoge/i0yVWXjVPwVUT+Fct8me1Z+ViS0Ne1x2ZafpXRzHrO7oj5fFS0zLJhbaUzHCF5LzkYu6/oz6m2NZ/khpR9BbCfSHeV4dvpOQ6nohHEHi6jC+f7OQMvxb4zimkfnEcu6+2PxFNn5QXki2s2D8OOc6xbWMB/nbAlJBOK4A+EK/E7vc5DpqMllc/Cly/CzjvMjkWcgJe3vyUjgXlNG/Qjcbhb/MQAXxYuK0/M6O41p/uM0wlowBhG4WTRnL/8MfFC3F8j/1QiDdO2JbdAAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$\\displaystyle 0.000158799793094937$"
      ],
      "text/plain": [
       "0.000158799793094937"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'theta=20, m=6'"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAANgAAAAUCAYAAADvCvMiAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHLklEQVR4Ae2ajXHVOBDH8zIUEHIVHNcBhA5CB+GoANJBGCrIQAdwFUCuA9IBl3QQOoCkg9z/p2jFWpYdyfbLzc14Z/QkS/vx12r1Yfltbm9vd1ZaPbB6YLoHNpvNE82j7yUNm3WCldyy1q0eqPeAJthHcT9RIu9MtHWC1ftx5Vw9UPSAJthXNRwWGj89KlSuVasHVg+0eeC7ToIbL8KuprrjdQfzXlnLqwcmeCB/B9Pze6k51QS72Z2gb5IIIJTeKO1NUvAAQv8HjNtyg/r+NNfNWOGTvH597npAEym9d8lfR2r9yuSCq7ODRSefqf6ZMcBUQ5Jl1kI/lP5Qel8wjO4huhH/Y2uUPl4YjfZVeF3CVMuHoqUxZjp5hD4L5+Vd8e5XdgnS41jHAsMz/jmPdSlr6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wnNJuJhI5mNe0pm4jE++Q7binAvtoeR7MbCE4bkTzIK9hMVWjfDulDFwqcEq3qM4yL+r4aUC8ESJXY7VlEsTKKzYtXziXxSjC8LSzsHNIpOLl91Bkg52AYL5zCZjQ39YfDjK5YE/aG9GA33kDwL4P1ALTpOZkuMXpVslfDqXpsbAXLs7s46IOFsOAERvxXZ1pUBk5S7Vo4vVk+DzN4sElQVUkqvh2xJGMIBxiFJACje7L33KFxSOiOzSJCZcVb+lD918Rkl+QHYOSSc3vLzbPhvQ0xlffCq+e8dnQFdVNTaEiz7ip1kUdaGj04+o1OoW86cHO2uCRUUcI1JAOeW2g3WOgXIaHYI/DzgnWiyyK3Ajx+COUYlvaYwMRqnPhisMVuxrWIFV5ibxPuwm7/O8P9h9Ln18N/PERGa3oZ4/n6Z3Q880UMZGaZUPYyhdNWOV4xwwVV8tu71Lg3rpHmdTDPSkp1aoE6ycIUmHfRRt/dBc+jDMjpM+pDobrNh8dOx8pHXtR2oLf9txdQQVMrz3GNYqPvhFHKmWxBj6YFgslw363LHDs1LvI26sTx9f9VzdH7Pn8yE7xqP2wbFVW+fjqJMBe/qzAPWiZpySGbRttpbIx+yorSkGlsCDjl0ZriJWY6XemVhKeNH/qTYcHwheFf5UCi/Ed7XplzZoaDVnMuWrKYHLS71fSWv5mJCLYpQ+VsNz9TPdgo70mZ2k85E9+go/0CfzQ3V/JFci9JGm0EdhsiN4kNczkwLiUsbTXJxe14OVJ8TAItjCn33lTI4VDM5BzDniEMzfBOyD8kDi4ys1x7T8/I3sOyW70OAq+lR8fkKoKl0vc2wqXmdHnhS4ekZ38fuS8FTxRZ2LYnQ40QtxnBrqMzueD1SCtPdn35b+SD6QZJgYjBtHRIjJz64Txk3ttWMLJjtW0hcWubfSc6O8Q7U4a213lE94qLUjvuoYmACjKPIv5GP/yOHaQGQAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$\\displaystyle 1.07990763941591 \\cdot 10^{-7}$"
      ],
      "text/plain": [
       "1.07990763941591e-7"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m = Symbol(\"m\")\n",
    "T1D = subsampledFpF.subs(n, 100000).subs(a, 2000).subs(s,2*m*theta).evalf()\n",
    "print(\"n=100000, a=2000, s=2*m*theta\")\n",
    "display(\"theta=10, m=2\",T1D.subs(theta,10).subs(m,2).evalf())\n",
    "display(\"theta=10, m=4\",T1D.subs(theta,10).subs(m,4).evalf())\n",
    "display(\"theta=10, m=6\",T1D.subs(theta,10).subs(m,6).evalf())\n",
    "display(\"theta=20, m=6\",T1D.subs(theta,20).subs(m,6).evalf())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Charts for SDR Paper\n",
    "\n",
    "      The following sections calculates the numbers for some of the SDR paper charts.\n",
    "      \n",
    "\n",
    "## Importance of large n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a=64 cells active, s=16 synapses on segment, dendritic threshold is theta=8\n",
      "\n",
      "+-------+------------+-------------+\n",
      "|     n |   sparsity |    prob(fp) |\n",
      "+=======+============+=============+\n",
      "|   300 | 0.213333   | 0.767798    |\n",
      "+-------+------------+-------------+\n",
      "|   500 | 0.128      | 0.0960845   |\n",
      "+-------+------------+-------------+\n",
      "|   700 | 0.0914286  | 0.00881794  |\n",
      "+-------+------------+-------------+\n",
      "|   900 | 0.0711111  | 0.00104201  |\n",
      "+-------+------------+-------------+\n",
      "|  1100 | 0.0581818  | 0.000161867 |\n",
      "+-------+------------+-------------+\n",
      "|  1300 | 0.0492308  | 3.16122e-05 |\n",
      "+-------+------------+-------------+\n",
      "|  1500 | 0.0426667  | 7.42838e-06 |\n",
      "+-------+------------+-------------+\n",
      "|  1700 | 0.0376471  | 2.02811e-06 |\n",
      "+-------+------------+-------------+\n",
      "|  1900 | 0.0336842  | 6.26297e-07 |\n",
      "+-------+------------+-------------+\n",
      "|  2100 | 0.0304762  | 2.14288e-07 |\n",
      "+-------+------------+-------------+\n",
      "|  2300 | 0.0278261  | 7.99418e-08 |\n",
      "+-------+------------+-------------+\n",
      "|  2500 | 0.0256     | 3.21078e-08 |\n",
      "+-------+------------+-------------+\n",
      "|  2700 | 0.0237037  | 1.37439e-08 |\n",
      "+-------+------------+-------------+\n",
      "|  2900 | 0.022069   | 6.2188e-09  |\n",
      "+-------+------------+-------------+\n",
      "|  3100 | 0.0206452  | 2.95443e-09 |\n",
      "+-------+------------+-------------+\n",
      "|  3300 | 0.0193939  | 1.46549e-09 |\n",
      "+-------+------------+-------------+\n",
      "|  3500 | 0.0182857  | 7.55427e-10 |\n",
      "+-------+------------+-------------+\n",
      "|  3700 | 0.0172973  | 4.03069e-10 |\n",
      "+-------+------------+-------------+\n",
      "|  3900 | 0.0164103  | 2.21856e-10 |\n",
      "+-------+------------+-------------+\n",
      "|  4100 | 0.0156098  | 1.25602e-10 |\n",
      "+-------+------------+-------------+\n",
      "|  4300 | 0.0148837  | 7.29566e-11 |\n",
      "+-------+------------+-------------+\n",
      "|  4500 | 0.0142222  | 4.33823e-11 |\n",
      "+-------+------------+-------------+\n",
      "|  4700 | 0.013617   | 2.63575e-11 |\n",
      "+-------+------------+-------------+\n",
      "|  4900 | 0.0130612  | 1.63342e-11 |\n",
      "+-------+------------+-------------+\n",
      "|  5100 | 0.012549   | 1.03095e-11 |\n",
      "+-------+------------+-------------+\n",
      "|  5300 | 0.0120755  | 6.6182e-12  |\n",
      "+-------+------------+-------------+\n",
      "|  5500 | 0.0116364  | 4.31603e-12 |\n",
      "+-------+------------+-------------+\n",
      "|  5700 | 0.0112281  | 2.85628e-12 |\n",
      "+-------+------------+-------------+\n",
      "|  5900 | 0.0108475  | 1.91632e-12 |\n",
      "+-------+------------+-------------+\n",
      "|  6100 | 0.0104918  | 1.30228e-12 |\n",
      "+-------+------------+-------------+\n",
      "|  6300 | 0.0101587  | 8.95705e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  6500 | 0.00984615 | 6.23064e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  6700 | 0.00955224 | 4.38047e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  6900 | 0.00927536 | 3.11077e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  7100 | 0.00901408 | 2.23014e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  7300 | 0.00876712 | 1.61321e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  7500 | 0.00853333 | 1.17691e-13 |\n",
      "+-------+------------+-------------+\n",
      "|  7700 | 0.00831169 | 8.65555e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  7900 | 0.00810127 | 6.4147e-14  |\n",
      "+-------+------------+-------------+\n",
      "|  8100 | 0.00790123 | 4.78877e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  8300 | 0.00771084 | 3.59988e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  8500 | 0.00752941 | 2.72413e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  8700 | 0.00735632 | 2.07451e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  8900 | 0.00719101 | 1.58937e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  9100 | 0.00703297 | 1.22474e-14 |\n",
      "+-------+------------+-------------+\n",
      "|  9300 | 0.00688172 | 9.49009e-15 |\n",
      "+-------+------------+-------------+\n",
      "|  9500 | 0.00673684 | 7.39263e-15 |\n",
      "+-------+------------+-------------+\n",
      "|  9700 | 0.00659794 | 5.78812e-15 |\n",
      "+-------+------------+-------------+\n",
      "|  9900 | 0.00646465 | 4.55405e-15 |\n",
      "+-------+------------+-------------+\n",
      "| 10100 | 0.00633663 | 3.59996e-15 |\n",
      "+-------+------------+-------------+\n",
      "| 10300 | 0.00621359 | 2.85863e-15 |\n",
      "+-------+------------+-------------+\n",
      "| 10500 | 0.00609524 | 2.27984e-15 |\n",
      "+-------+------------+-------------+\n",
      "| 10700 | 0.00598131 | 1.82587e-15 |\n",
      "+-------+------------+-------------+\n",
      "| 10900 | 0.00587156 | 1.4682e-15  |\n",
      "+-------+------------+-------------+\n",
      "| 11100 | 0.00576577 | 1.18519e-15 |\n",
      "+-------+------------+-------------+\n",
      "| 11300 | 0.00566372 | 9.60331e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 11500 | 0.00556522 | 7.80958e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 11700 | 0.00547009 | 6.37316e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 11900 | 0.00537815 | 5.21857e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 12100 | 0.00528926 | 4.28716e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 12300 | 0.00520325 | 3.53316e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 12500 | 0.00512    | 2.92072e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 12700 | 0.00503937 | 2.42162e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 12900 | 0.00496124 | 2.0136e-16  |\n",
      "+-------+------------+-------------+\n",
      "| 13100 | 0.0048855  | 1.67901e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 13300 | 0.00481203 | 1.40382e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 13500 | 0.00474074 | 1.17682e-16 |\n",
      "+-------+------------+-------------+\n",
      "| 13700 | 0.00467153 | 9.89051e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 13900 | 0.00460432 | 8.33307e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 14100 | 0.00453901 | 7.03782e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 14300 | 0.00447552 | 5.95786e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 14500 | 0.00441379 | 5.05513e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 14700 | 0.00435374 | 4.2987e-17  |\n",
      "+-------+------------+-------------+\n",
      "| 14900 | 0.0042953  | 3.66337e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 15100 | 0.00423841 | 3.12851e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 15300 | 0.00418301 | 2.67722e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 15500 | 0.00412903 | 2.2956e-17  |\n",
      "+-------+------------+-------------+\n",
      "| 15700 | 0.00407643 | 1.97222e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 15900 | 0.00402516 | 1.6976e-17  |\n",
      "+-------+------------+-------------+\n",
      "| 16100 | 0.00397516 | 1.46393e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 16300 | 0.00392638 | 1.26471e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 16500 | 0.00387879 | 1.09452e-17 |\n",
      "+-------+------------+-------------+\n",
      "| 16700 | 0.00383234 | 9.48866e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 16900 | 0.00378698 | 8.23977e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 17100 | 0.00374269 | 7.16699e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 17300 | 0.00369942 | 6.24389e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 17500 | 0.00365714 | 5.4482e-18  |\n",
      "+-------+------------+-------------+\n",
      "| 17700 | 0.00361582 | 4.7612e-18  |\n",
      "+-------+------------+-------------+\n",
      "| 17900 | 0.00357542 | 4.16705e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 18100 | 0.00353591 | 3.6524e-18  |\n",
      "+-------+------------+-------------+\n",
      "| 18300 | 0.00349727 | 3.20589e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 18500 | 0.00345946 | 2.81792e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 18700 | 0.00342246 | 2.4803e-18  |\n",
      "+-------+------------+-------------+\n",
      "| 18900 | 0.00338624 | 2.18606e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 19100 | 0.00335079 | 1.92926e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 19300 | 0.00331606 | 1.70482e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 19500 | 0.00328205 | 1.5084e-18  |\n",
      "+-------+------------+-------------+\n",
      "| 19700 | 0.00324873 | 1.33625e-18 |\n",
      "+-------+------------+-------------+\n",
      "| 19900 | 0.00321608 | 1.18519e-18 |\n",
      "+-------+------------+-------------+\n",
      "[0.767798046805888, 0.0960845416487165, 0.00881793984023789, 0.00104201059477680, 0.000161866998734267, 3.16121753895779e-5, 7.42838135168482e-6, 2.02810556367455e-6, 6.26296994067198e-7, 2.14288245865589e-7, 7.99418222318950e-8, 3.21077808048928e-8, 1.37438883181648e-8, 6.21879891409450e-9, 2.95443192395266e-9, 1.46548703909345e-9, 7.55426623928377e-10, 4.03069042524778e-10, 2.21855613504858e-10, 1.25602427254846e-10, 7.29565898352752e-11, 4.33823270726987e-11, 2.63574676030204e-11, 1.63341677848632e-11, 1.03094878512466e-11, 6.61820425636368e-12, 4.31602894863397e-12, 2.85628272660169e-12, 1.91632278470408e-12, 1.30228251757813e-12, 8.95704526501288e-13, 6.23063767783764e-13, 4.38047430918503e-13, 3.11076993767398e-13, 2.23013796374613e-13, 1.61321052161476e-13, 1.17690561046501e-13, 8.65555486648568e-14, 6.41470046810705e-14, 4.78877290083649e-14, 3.59988148092467e-14, 2.72413367559495e-14, 2.07450519186865e-14, 1.58936937437398e-14, 1.22474470259293e-14, 9.49008634350598e-15, 7.39262555848706e-15, 5.78811819582042e-15, 4.55405220189980e-15, 3.59995870603115e-15, 2.85862824712372e-15, 2.27984148947650e-15, 1.82586511021711e-15, 1.46819534023413e-15, 1.18518918830356e-15, 9.60331248430696e-16, 7.80958371258306e-16, 6.37316119269338e-16, 5.21857011831390e-16, 4.28715944127415e-16, 3.53316120669355e-16, 2.92071624826489e-16, 2.42161894566693e-16, 2.01359959726941e-16, 1.67901061328122e-16, 1.40381739546325e-16, 1.17682010751169e-16, 9.89051152843804e-17, 8.33306913245833e-17, 7.03782486292717e-17, 5.95785743686907e-17, 5.05512704847369e-17, 4.29870479976394e-17, 3.66337249063553e-17, 3.12851175067647e-17, 2.67721997530410e-17, 2.29560462498643e-17, 1.97221823764714e-17, 1.69760479483278e-17, 1.46393447333667e-17, 1.26470875739574e-17, 1.09452172272728e-17, 9.48866290051899e-18, 8.23976577817741e-18, 7.16699310476475e-18, 6.24388673637030e-18, 5.44820137970605e-18, 4.76119666953519e-18, 4.16705431178299e-18, 3.65239714098025e-18, 3.20589141787563e-18, 2.81791726811520e-18, 2.48029502476245e-18, 2.18605753401716e-18, 1.92926033086935e-18, 1.70482308095028e-18, 1.50839688859563e-18, 1.33625304613249e-18, 1.18518959085345e-18]\n",
      "[300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500, 2700, 2900, 3100, 3300, 3500, 3700, 3900, 4100, 4300, 4500, 4700, 4900, 5100, 5300, 5500, 5700, 5900, 6100, 6300, 6500, 6700, 6900, 7100, 7300, 7500, 7700, 7900, 8100, 8300, 8500, 8700, 8900, 9100, 9300, 9500, 9700, 9900, 10100, 10300, 10500, 10700, 10900, 11100, 11300, 11500, 11700, 11900, 12100, 12300, 12500, 12700, 12900, 13100, 13300, 13500, 13700, 13900, 14100, 14300, 14500, 14700, 14900, 15100, 15300, 15500, 15700, 15900, 16100, 16300, 16500, 16700, 16900, 17100, 17300, 17500, 17700, 17900, 18100, 18300, 18500, 18700, 18900, 19100, 19300, 19500, 19700, 19900]\n"
     ]
    }
   ],
   "source": [
    "eq1 = subsampledFpFSlow.subs(s, 64).subs(theta, 12)\n",
    "print(\"a=64 cells active, s=16 synapses on segment, dendritic threshold is theta=8\\n\")\n",
    "errorList = []\n",
    "nList = []\n",
    "table = [[\"n\", \"sparsity\", \"prob(fp)\"]]\n",
    "for n0 in range(300,20100,200):\n",
    "    error = eq1.subs(n, n0).subs(a,64).evalf()\n",
    "    errorList += [error]\n",
    "    nList += [n0]\n",
    "    table.append([n0, 64/n0, error])\n",
    "\n",
    "print (tabulate(table, headers=\"firstrow\", tablefmt=\"grid\"))\n",
    "print(errorList)\n",
    "print(nList)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## n = a/2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a=n/2 cells active, s=24 synapses on segment, dendritic threshold is theta=12\n",
      "\n",
      "+------+------------+------------+\n",
      "|    n |   sparsity |   prob(fp) |\n",
      "+======+============+============+\n",
      "|  300 |        0.5 |   0.584015 |\n",
      "+------+------------+------------+\n",
      "|  500 |        0.5 |   0.582595 |\n",
      "+------+------------+------------+\n",
      "|  700 |        0.5 |   0.582007 |\n",
      "+------+------------+------------+\n",
      "|  900 |        0.5 |   0.581686 |\n",
      "+------+------------+------------+\n",
      "| 1100 |        0.5 |   0.581484 |\n",
      "+------+------------+------------+\n",
      "| 1300 |        0.5 |   0.581344 |\n",
      "+------+------------+------------+\n",
      "| 1500 |        0.5 |   0.581242 |\n",
      "+------+------------+------------+\n",
      "| 1700 |        0.5 |   0.581165 |\n",
      "+------+------------+------------+\n",
      "| 1900 |        0.5 |   0.581104 |\n",
      "+------+------------+------------+\n",
      "| 2100 |        0.5 |   0.581055 |\n",
      "+------+------------+------------+\n",
      "| 2300 |        0.5 |   0.581014 |\n",
      "+------+------------+------------+\n",
      "| 2500 |        0.5 |   0.58098  |\n",
      "+------+------------+------------+\n",
      "| 2700 |        0.5 |   0.580951 |\n",
      "+------+------------+------------+\n",
      "| 2900 |        0.5 |   0.580926 |\n",
      "+------+------------+------------+\n",
      "| 3100 |        0.5 |   0.580904 |\n",
      "+------+------------+------------+\n",
      "| 3300 |        0.5 |   0.580885 |\n",
      "+------+------------+------------+\n",
      "| 3500 |        0.5 |   0.580868 |\n",
      "+------+------------+------------+\n",
      "[0.584014929308308, 0.582594747080399, 0.582007206016863, 0.581686021979051, 0.581483533877904, 0.581344204898149, 0.581242471033283, 0.581164924569868, 0.581103856001899, 0.581054517612207, 0.581013825794851, 0.580979690688467, 0.580950645707841, 0.580925631309445, 0.580903862938630, 0.580884747253428, 0.580867827216677]\n",
      "[300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500, 2700, 2900, 3100, 3300, 3500]\n"
     ]
    }
   ],
   "source": [
    "eq1 = subsampledFpFSlow.subs(s, 24).subs(theta, 12)\n",
    "print (\"a=n/2 cells active, s=24 synapses on segment, dendritic threshold is theta=12\\n\")\n",
    "errorList = []\n",
    "nList = []\n",
    "table = [[\"n\", \"sparsity\", \"prob(fp)\"]]\n",
    "for n0 in range(300,3700,200):\n",
    "    error = eq1.subs(n, n0).subs(a,n0/2).evalf()\n",
    "    errorList += [error]\n",
    "    nList += [n0]\n",
    "    table.append([n0, (n0/2)/n0, error])\n",
    "\n",
    "print (tabulate(table, headers=\"firstrow\", tablefmt=\"grid\"))\n",
    "print (errorList)\n",
    "print (nList)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Small sparsity is insufficient"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2% sparsity with n=400\n",
      "0.00206314616966578\n",
      "2% sparsity with n=4000\n",
      "0.0522148720308419\n"
     ]
    }
   ],
   "source": [
    "print (\"2% sparsity with n=400\")\n",
    "print subsampledFpFSlow.subs(s, 4).subs(a, 8).subs(theta, 2).subs(n,400).evalf()\n",
    "print (\"2% sparsity with n=4000\")\n",
    "print subsampledFpFSlow.subs(s, 4).subs(a, 400).subs(theta, 2).subs(n,4000).evalf()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## A small subsample can be very reliable (but not too small)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a=200 cells active out of population of n=10000 cells\n",
      "\n",
      "synapses s =   2, theta = s/2 =   1, probability of false match =  0.0591029102910291\n",
      "synapses s =   3, theta = s/2 =   1, probability of false match =  0.0873354694941389\n",
      "synapses s =   4, theta = s/2 =   2, probability of false match =  0.00517101241148655\n",
      "synapses s =   5, theta = s/2 =   2, probability of false match =  0.00844794620736664\n",
      "synapses s =   6, theta = s/2 =   3, probability of false match =  0.000499865412306804\n",
      "synapses s =   7, theta = s/2 =   3, probability of false match =  0.000855357919350205\n",
      "synapses s =   8, theta = s/2 =   4, probability of false match =  5.05282906751424e-5\n",
      "synapses s =   9, theta = s/2 =   4, probability of false match =  8.88044155296650e-5\n",
      "synapses s =  10, theta = s/2 =   5, probability of false match =  5.23462085992797e-6\n",
      "synapses s =  11, theta = s/2 =   5, probability of false match =  9.36152430040881e-6\n",
      "synapses s =  12, theta = s/2 =   6, probability of false match =  5.50467708713271e-7\n",
      "synapses s =  13, theta = s/2 =   6, probability of false match =  9.96590775459112e-7\n",
      "synapses s =  14, theta = s/2 =   7, probability of false match =  5.84458284016591e-8\n",
      "synapses s =  15, theta = s/2 =   7, probability of false match =  1.06781055245346e-7\n",
      "synapses s =  16, theta = s/2 =   8, probability of false match =  6.24488987535941e-9\n",
      "synapses s =  17, theta = s/2 =   8, probability of false match =  1.14900993578035e-8\n",
      "synapses s =  18, theta = s/2 =   9, probability of false match =  6.70048689113995e-10\n",
      "synapses s =  19, theta = s/2 =   9, probability of false match =  1.23977606153067e-9\n",
      "synapses s =  20, theta = s/2 =  10, probability of false match =  7.20851539659221e-11\n",
      "synapses s =  21, theta = s/2 =  10, probability of false match =  1.33990428897848e-10\n",
      "synapses s =  22, theta = s/2 =  11, probability of false match =  7.76731651059463e-12\n",
      "synapses s =  23, theta = s/2 =  11, probability of false match =  1.44929751014167e-11\n",
      "synapses s =  24, theta = s/2 =  12, probability of false match =  8.37584522709849e-13\n",
      "synapses s =  25, theta = s/2 =  12, probability of false match =  1.56790489972169e-12\n",
      "synapses s =  26, theta = s/2 =  13, probability of false match =  9.03331595141546e-14\n",
      "synapses s =  27, theta = s/2 =  13, probability of false match =  1.69568150423906e-13\n",
      "synapses s =  28, theta = s/2 =  14, probability of false match =  9.73897092618566e-15\n",
      "synapses s =  29, theta = s/2 =  14, probability of false match =  1.83255953842929e-14\n",
      "synapses s =  30, theta = s/2 =  15, probability of false match =  1.04919182521237e-15\n",
      "[0.0591029102910291, 0.0873354694941389, 0.00517101241148655, 0.00844794620736664, 0.000499865412306804, 0.000855357919350205, 5.05282906751424e-5, 8.88044155296650e-5, 5.23462085992797e-6, 9.36152430040881e-6, 5.50467708713271e-7, 9.96590775459112e-7, 5.84458284016591e-8, 1.06781055245346e-7, 6.24488987535941e-9, 1.14900993578035e-8, 6.70048689113995e-10, 1.23977606153067e-9, 7.20851539659221e-11, 1.33990428897848e-10, 7.76731651059463e-12, 1.44929751014167e-11, 8.37584522709849e-13, 1.56790489972169e-12, 9.03331595141546e-14, 1.69568150423906e-13, 9.73897092618566e-15, 1.83255953842929e-14, 1.04919182521237e-15]\n",
      "[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n"
     ]
    }
   ],
   "source": [
    "eq2 = subsampledFpFSlow.subs(n, 10000).subs(a, 300)\n",
    "print(\"a=200 cells active out of population of n=10000 cells\\n\")\n",
    "errorList = []\n",
    "sList = []\n",
    "for s0 in range(2,31,1):\n",
    "    print \"synapses s = %3d, theta = s/2 = %3d, probability of false match = \"%(s0,s0/2), eq2.subs(s, s0).subs(theta,s0/2).evalf() \n",
    "    errorList += [eq2.subs(s, s0).subs(theta,s0/2).evalf()]\n",
    "    sList += [s0]\n",
    "    \n",
    "print (errorList)\n",
    "print (sList)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Impact of noise on false negatives"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "b = Symbol(\"b\")\n",
    "v = Symbol(\"v\")\n",
    "theta = Symbol(\"theta\")\n",
    "s = Symbol(\"s\")\n",
    "a = Symbol(\"a\")\n",
    "\n",
    "overlapSetNoise = (binomial(s, b) * binomial(a - s, v - b)) / binomial(a, v)\n",
    "noiseFN = Sum(overlapSetNoise, (b, s-theta+1, s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a=128 cells active with segment containing s=30 synapses (n doesn't matter here)\n",
      "\n",
      "theta =  8\n",
      "[0, 0, 0, 3.11341516283240e-16, 2.23243424464799e-12, 7.90168637530306e-10, 1.20695707971664e-7, 3.45576265561118e-6, 8.08202472708491e-5, 0.000735429456875121, 0.00464043435771348, 0.0268657157114204, 0.0896352007201254, 0.263952754229579, 0.508714577385333, 0.770861966941236]\n",
      "[0.046875, 0.1015625, 0.1484375, 0.203125, 0.25, 0.296875, 0.3515625, 0.3984375, 0.453125, 0.5, 0.546875, 0.6015625, 0.6484375, 0.703125, 0.75, 0.796875]\n",
      "theta =  12\n",
      "[0, 0, 2.48810797387309e-15, 7.92695349343630e-10, 2.16302525195240e-7, 1.09248135880715e-5, 0.000314435369055385, 0.00279559866084888, 0.0198782675563797, 0.0716985160403564, 0.190430462690358, 0.426525969583828, 0.664766152465367, 0.880922510721824, 0.970339402698393, 0.996376835285247]\n",
      "[0.046875, 0.1015625, 0.1484375, 0.203125, 0.25, 0.296875, 0.3515625, 0.3984375, 0.453125, 0.5, 0.546875, 0.6015625, 0.6484375, 0.703125, 0.75, 0.796875]\n",
      "theta =  16\n",
      "[0, 0, 2.65549705827547e-8, 1.97277260559420e-5, 0.000590078912236923, 0.00627504390204146, 0.0434711883681422, 0.139067254386793, 0.351117043857492, 0.582501773030327, 0.788076297517739, 0.933878292787173, 0.983735005386502, 0.998319255844748, 0.999889798557155, 0.999997748076386]\n",
      "[0.046875, 0.1015625, 0.1484375, 0.203125, 0.25, 0.296875, 0.3515625, 0.3984375, 0.453125, 0.5, 0.546875, 0.6015625, 0.6484375, 0.703125, 0.75, 0.796875]\n"
     ]
    }
   ],
   "source": [
    "eqn = noiseFN.subs(s, 30).subs(a, 128)\n",
    "print (\"a=128 cells active with segment containing s=30 synapses (n doesn't matter here)\\n\")\n",
    "for t in range(8,20,4):\n",
    "    print (\"theta = \",t)\n",
    "    errorList = []\n",
    "    noiseList = []\n",
    "    noisePct = 0.05\n",
    "    while noisePct <= 0.85:\n",
    "        noise = int(round(noisePct*128,0))\n",
    "        errorList += [eqn.subs(v, noise).subs(theta,t).evalf()]\n",
    "        noiseList += [noise/128.0]\n",
    "        noisePct += 0.05\n",
    "    print (errorList)\n",
    "    print (noiseList)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Impact of noise on first-order TMs trained on one sequence\n",
    "We assume that false positives are impossible -- this is in fact not strictly true, but the number of segments is so low that it might as well be."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'c' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-15-fdbe6a54783c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0meqn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnoiseFN\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0meqn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meqn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m20\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m40\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m40\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mt\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m     \u001b[0;32mprint\u001b[0m \u001b[0;34m\"theta = \"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0merrorList\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'c' is not defined"
     ]
    }
   ],
   "source": [
    "eqn = noiseFN\n",
    "eqn = eqn.subs(s, 20).subs(a, 40).subs(c, 40)\n",
    "for t in range(8, 20, 4):\n",
    "    print \"theta = \",t\n",
    "    errorList = []\n",
    "    jaccardSimilarityList = []\n",
    "    noiseList = []\n",
    "    noisePct = 0.00\n",
    "    while noisePct <= 1:\n",
    "        noise = int(round(noisePct*40,0))\n",
    "        error = eqn.subs(v, noise).subs(theta,t).evalf()\n",
    "        errorList.append(error)\n",
    "        jaccardSimilarity = 1 - error\n",
    "        jaccardSimilarityList.append(jaccardSimilarity)\n",
    "        noiseList += [noise/40.0]\n",
    "        noisePct += 0.05\n",
    "    print errorList\n",
    "    print jaccardSimilarityList\n",
    "    print noiseList"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Charts for BAMI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a=32 cells active, s=32 synapses on segment, dendritic threshold is s/2\n",
      "\n",
      "population n =    50, sparsity =  0.5000%, probability of false match =  0.713930783595416\n",
      "population n =   100, sparsity =  0.5000%, probability of false match =  0.579192330580665\n",
      "population n =   150, sparsity =  0.5000%, probability of false match =  0.627949560779490\n",
      "population n =   200, sparsity =  0.5000%, probability of false match =  0.556207787852021\n",
      "population n =   250, sparsity =  0.5000%, probability of false match =  0.599827556589778\n",
      "population n =   300, sparsity =  0.5000%, probability of false match =  0.545950866779313\n",
      "population n =   350, sparsity =  0.5000%, probability of false match =  0.584632630831763\n",
      "population n =   400, sparsity =  0.5000%, probability of false match =  0.539819496834182\n",
      "population n =   450, sparsity =  0.5000%, probability of false match =  0.574768441538204\n",
      "[0.713930783595416, 0.579192330580665, 0.627949560779490, 0.556207787852021, 0.599827556589778, 0.545950866779313, 0.584632630831763, 0.539819496834182, 0.574768441538204]\n",
      "[50, 100, 150, 200, 250, 300, 350, 400, 450]\n"
     ]
    }
   ],
   "source": [
    "w0 = 32\n",
    "print (\"a=%d cells active, s=%d synapses on segment, dendritic threshold is s/2\\n\" % (w0,w0))\n",
    "errorList = []\n",
    "nList = []\n",
    "for n0 in range(50,500,50):\n",
    "    w0 = n0/2\n",
    "    eq1 = subsampledFpFSlow.subs(s, w0).subs(theta, w0/2)\n",
    "    error = eq1.subs(n, n0).subs(a,w0).evalf()\n",
    "    errorList += [error]\n",
    "    nList += [n0]\n",
    "    print (\"population n = %5d, sparsity = %7.4f%%, probability of false match = \"%(n0, float(w0)/n0), error)\n",
    "    \n",
    "print (errorList)\n",
    "print (nList)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Union Property Math\n",
    "Here, we calculate the expected error rates for unions of various sizes, with varying dimensions and sparsities.\n",
    "This is used in plots for the Neuron paper."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh0AAABDCAYAAAA4e7dJAAAABHNCSVQICAgIfAhkiAAAEUNJREFU\neJzt3XvUHHV9x/H3w/NAyF1ykZCqCSHRCBqQIC2Vm0T0EEQQGiBAFSFeMQgIhHBOy2MBIYDAOY2o\nxxS0nhpQEORuaanQxAoWLFpBwABKFSy5gJGLEPL0j+9sd3ae2Znfb36zO7vPfl7n5GQv85v57u73\n2Z35XUFERERkhDoC2L3qIKQrzAM+XHUQIiJSjm3afLwDgBnAQ20+btzcisuHmANMc9huDLBzi2Mp\nwjeunwF/BuzfmnBERGSk6gN+AGwXsI+zA2NYCsyusHyoS4GxjtsuY3isB0T7OArYF/gy8AHgI8Dh\nJcVYJK645Ge8PXA7lj8iItLFitZ0PAic6FlmIVbD8WrBY4JdKRf1fmAj8KuSy48HrgfeUjw0J6OA\nfuBFx+0vA86n8TP+NVZzcDfwY2AX7ETwGWBKaZGaZu9LWlxxyc/4FeAR7P0XEZEuVvSk4zzgLs8y\nC4E1BY9XhlOBa0suvwT4PFZz0OqmqiOAmz22fx07uVgUe+x/sJqDTcA+0fNg/SbuBSY77vuzOc9n\nvS9pceVZCxzqsb2IiHSgoj+UtwC/9SyzL9X15ZiH/eC+XnL5VcBg8bC87A/c41nmNqzppGZ34IfR\n7X2AW6Pbm4HdgA2O+82rFcl7X5Jx5XkI2M9jexER6UAD0f+HARdh1eFPRY8djv1w7IFV6+8DfBI4\nCPgicAOwIqXsEHZVfgKNTQE7Yc0TyeOfBzwNbIvVhpwKrHOMfxLwUayvwsX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G97HDgu1UH0eHux/ph5VFeVUM5HCYrv2djNQ8utsGmMB8Te+wMbIHBmtpso806nZ6LdRv4\nf5oczM/fYhOuPNqi/TebA1+y/QO2yN4pwKsVx1K1g7ET2GOwq5CrsAWdxOyCrZB5o8O2yis/A8B5\nwNPYwpcLgVPxX61XOVxcXn4fh9tCcGBDZpdhv3vnRI9tot4pdBw2Cuavo/0mf79mYCvSDlveXmQk\nuA5rsup1jwJ/Ht3+IHBzhbF0opXUv0BdKK/c+bb1N6McLi4vv2/BThZ8LKLenWB77HNejA2m+Jvo\n3yEp5a4gNimYyEgzBxttsG3VgVRoBvBY7P4S3BZ96hXTsdWfx+RtGKO8cpPX1r8UuDLj3+JoO+Vw\ncUXyW0QCLMPOunvVkcDVsfvXYdXdYr5L+hVZnl7PKxe+bf3NKIeLK5rfbaXJwWQkuRTYA9i76kAq\n8gfg+ej2HOzq80vVhdNRTsA6gd9RoGyv55WLtLb+tVhbvw/lcDEh+S0iAUZjHaWmVh1IBbbBvqBP\nxDrfTa80ms6xO9bWnbaEt6tezisXPm39WZTD/srIb+lQrZi0Ziz2x3kiw8dEi4iISI8qe9KaPmzM\ndG3Wt9XAW0vat4iISEdRnw4/B2Fz1pe1uNtJ2AnMA9H9MdjkLSIiIiOOJgfzkzVpzSTgLLLb1bYA\nXwBei7ZbHv2reRc2Z76IiIj0uDInrdkLO/kYxCZzuQR4Gf+JW0RERLqCajrczcBqJ+6L7k8jrCf7\n3tgc+YPR/TOAa7EJdkREREYcnXS4mw+sid0/mMbJcCYDZ+LevDIBeDB6vA84Gf8x7SIiIl1DJx3u\n0iatOTn2/AYa+2fkWQdMjG5/DLgBeCgwRhERkY5V1tDPXvAUVrsxHfgrbE2ADQH7ewxbSGca1o9j\nRWB8IiIiIiIiIiIiIiIiIiIiIiIiIiJe/g9u6ztLxG5NqgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "Min(a, floor(n*(-(1 - s/n)**m + 1)))                                          \n",
       "              _______                                                         \n",
       "              ╲                                                               \n",
       "               ╲                     ⎛  ⎛           m    ⎞⎞ ⎛    ⎛           m\n",
       "                ╲                    ⎜  ⎜  ⎛  a    ⎞     ⎟⎟ ⎜    ⎜  ⎛  a    ⎞ \n",
       "                 ╲                   ⎜n⋅⎜- ⎜- ─ + 1⎟  + 1⎟⎟ ⎜- n⋅⎜- ⎜- ─ + 1⎟ \n",
       "                  ╲                  ⎜  ⎝  ⎝  n    ⎠     ⎠⎟⋅⎜    ⎝  ⎝  n    ⎠ \n",
       "                   ╲                 ⎜                    ⎟ ⎜                 \n",
       "                   ╱                 ⎝         b          ⎠ ⎝          a - b  \n",
       "                  ╱                  ─────────────────────────────────────────\n",
       "                 ╱                                           ⎛n⎞              \n",
       "                ╱                                            ⎜ ⎟              \n",
       "               ╱                                             ⎝a⎠              \n",
       "              ╱                                                               \n",
       "              ‾‾‾‾‾‾‾                                                         \n",
       "               b = θ                                                          \n",
       "\n",
       "          \n",
       "          \n",
       "          \n",
       "    ⎞    ⎞\n",
       "    ⎟    ⎟\n",
       " + 1⎟ + n⎟\n",
       "    ⎠    ⎟\n",
       "         ⎟\n",
       "         ⎠\n",
       "──────────\n",
       "          \n",
       "          \n",
       "          \n",
       "          \n",
       "          \n",
       "          "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "oxd = Symbol(\"omega\")\n",
    "n = Symbol(\"n\")\n",
    "a = Symbol(\"a\")\n",
    "b = Symbol(\"b\")\n",
    "theta = Symbol(\"theta\")\n",
    "s = Symbol(\"s\")\n",
    "m = Symbol(\"m\")\n",
    "q = Symbol(\"q\")\n",
    "\n",
    "p = (1 - a/n) ** m\n",
    "ss = Min(floor((1 - (1 - s/n)**m)*n), a)\n",
    "\n",
    "expectedUnionOverlap =  binomial(((1 - p)*n), b) * binomial(((n - (1 - p)*n)), a - b) / binomial(n, a)\n",
    "expectedUnionFP = Sum(expectedUnionOverlap, (b, theta, ss))\n",
    "\n",
    "display(expectedUnionFP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABX8AAABFCAYAAAASC5WaAAAABHNCSVQICAgIfAhkiAAAIABJREFU\neJzt3Xm8HUWZ//FPkptAAkkI+xIgbFFZlFVAloBsKuuAwyYQQNQwgDIqghsGER12RBbBGbmAIogC\nAziAM0jUEVlcRkSQVQQE2YmIbIH8/ni6f7dvp5en+lSfk3vv9/163VfO6VOnuk7V09UndaqrQURE\nRERERERERESGnTE92OciwJ7APT3Y98JqVWAd4EXgwOTxkcANwGjg88BqwNrA3cDqwEzg/4B5uby2\nBV4BXu5GwRdS2wGvAy/1uiAiIiIiIiIiIiIjxSjgZGBirwuyEJkMnJg83hU4LXn8a2B94ABgv2Tb\nfwCLAjOA14C/AX8Fvp/JbxTw1STdSJXG2eReF0RERERERERERGSkOAKbmSoDTgWWTh6PxgbGx2GD\nvxOA84Gtk9dPATYDdgHGJttmANNyea4MnNBaiYeGZYCzel0IERERERERERGRXhndxX1NwAYtb2kp\n/8+0lG+bpmIDvc8mz9/CBn+PAY4F/pG81pe8PhpYCbgeeAOYlDx/JJfvY8CSwHKZbTOwgea9gC2B\nc4GdgIOA3SvKOBTrFeAZbOmLdXpdEBERERERERERkV5oOvj7G+DgwPfsxeDlCfJOxwYlUxsDZ2Nr\n234LWLMm/wmB5akSUpamrwF8DOjPbXsCOAk4Dpu9eg0wPXltHWyAOPUJ4D9LPsPVwIcyz/+MDRT/\nBLgNWAO4CXiSgZnHRWLWa6pb9ftdYFbMgouIiIiIiIiIiAx3u2IDiSEuwW5UVmQG8BSwTfJ8HDZY\nuULyfBPgzpr8ZweWp0xIWZq+lrqJwQPwozKPL8NujAewI/ABbLbuWpm0P6n4HIsD12ae9wFXJY+3\nYmBG73lJnkuV5DO7Yh9ZRzrTdbN+AX7rLJeIiIiIiIiIiMiw0nTm73XAXwLfsw7wcMH2ycC7gHsz\n22YAf8dm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iIiIiIiIiIiIiIiIiIiIiIiIiIiIjU+H+AUQgh\nOdG7/wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "Min(40, floor(-4000*(397/400)**m) + 4000)                                     \n",
       "                  ______                                                      \n",
       "                  ╲                                                           \n",
       "                   ╲                                                     ⎛    \n",
       "                    ╲                                                    ⎜    \n",
       "                     ╲                                                   ⎜4000\n",
       "                      ╲                                                  ⎜    \n",
       "                      ╱                                                  ⎜    \n",
       "                     ╱                                                   ⎝  -b\n",
       "                    ╱                     ────────────────────────────────────\n",
       "                   ╱                      121839193013861927955851894070458217\n",
       "                  ╱                                                           \n",
       "                  ‾‾‾‾‾‾                                                      \n",
       "                  b = 15                                                      \n",
       "\n",
       "                                                             \n",
       "                                                             \n",
       "                                                             \n",
       "      m⎞ ⎛            m       ⎞                              \n",
       " ⎛ 99⎞ ⎟ ⎜       ⎛ 99⎞        ⎟                              \n",
       "⋅⎜───⎟ ⎟ ⎜- 4000⋅⎜───⎟  + 4000⎟                              \n",
       " ⎝100⎠ ⎟⋅⎜       ⎝100⎠        ⎟                              \n",
       "       ⎟ ⎜                    ⎟                              \n",
       " + 40  ⎠ ⎝         b          ⎠                              \n",
       "─────────────────────────────────────────────────────────────\n",
       "1559368245663254409399842941760054431871228116354726833248400\n",
       "                                                             \n",
       "                                                             \n",
       "                                                             "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 0\n",
      "1 0.000000000000000000001745032216871438090517748709430240184404544869372092932990501764967163185476624815904215229805420692\n",
      "2 0.0000000000000002093468685928811801989717729017516091277687796544570405122615488775764198833250143098252085743081943\n",
      "3 0.0000000000001091758776979344433495190028335131313256945573398716353241939392444505507255409008113375381478068025\n",
      "4 0.000000000007575918762457399263916640767599584844271471997036011048438470323012907960591826464196106810238596218\n",
      "5 0.0000000001814421512098364828902010548712515048686609396337277833566447515902789676799747568196961072283645763\n",
      "6 0.000000002248520791277327492290796623999930059599315117596382321155353679106977615017740475810202854920301505\n",
      "7 0.00000001779329137132590681767775746815254927118928197200267985021165612640886614001871820394749448092383756\n",
      "8 0.0000001017201482488728819151737506974190201700891964811656321916877721839928071431788182545666671963198185\n",
      "9 0.0000004544626711472886148782943170010378460105169655813186634988460443436161509812037269859880281873716257\n",
      "10 0.000001673545205416077459724790345759409758555860083672651394312442782337716385262891408052080307872762011\n",
      "11 0.000005274634381890824649967731453786697075580030725623346216696757615231015528962224029456798627635286104\n",
      "12 0.00001462791199478933856746051940481505112034594542712133079374880098530818256811892331207461912043358368\n",
      "13 0.00003644979576418442097730393509143113446076968166508018205759159074578781720107325971584123538102030605\n",
      "14 0.00008294107081500744874715114375028943571885033637485231209595101339269906442780758764550203782350796674\n",
      "15 0.0001745701338736711885975171319200187654810183764638769182399278538915889494881529886896615133443282304\n",
      "16 0.0003433768379824176943612680133133248469921353393738076151602423309472573544939086725543208776043038801\n",
      "17 0.0006365407870000748797865803930872278872799954552777804103952419844628528741500949482368939864597206811\n",
      "18 0.001119844416140449358299231800844055558202129038822569334973665690811165740170523679043437409612731079\n",
      "19 0.001880589932142477141139829155520709964107073600076870829583643475233179857435025035669660077977883288\n",
      "20 0.003029516466704932995869284049555306241680409015559002643762774910238281926314100999784074530679865040\n",
      "21 0.004701315022275674434827093613270219189440105084064340308316476402237748050567994294891107880340534753\n",
      "22 0.007053448113907231068129722312763114182905519715788955001662133948945080140966459086644688604308348714\n",
      "23 0.01026313329712844090376873239544988462442396408799465192075410874713792107070085924575382566497596026\n",
      "24 0.01452252404418872384635156536920806209226258673667343530521979074654362702316663747273265559965985879\n",
      "25 0.02003229487143450552807350008694978229905090583843567119834226766230788892191024835219285847048641993\n",
      "26 0.02699398926227861796362222287395173577731546137357835818779537047858009178890456816425422323353628860\n",
      "27 0.03560160246339447789921941579335705799323130239575454325807580112481064701853903602736196311323876529\n",
      "28 0.04603293663272091757741901569331072811854673259582932550477183274585855827236602007762478479240060083\n",
      "29 0.05844127978667884439913199409065146564937159941719975460908440338646401658633179450049951565867057525\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-18-43e8f497ac7a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0meq2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meq1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnum_patterns\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m     \u001b[0;31m#display(eq2)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m     \u001b[0merror_prob\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meq2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m100\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      8\u001b[0m     \u001b[0;32mprint\u001b[0m \u001b[0mnum_patterns\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merror_prob\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/evalf.pyc\u001b[0m in \u001b[0;36mevalf\u001b[0;34m(self, n, subs, maxn, chop, strict, quad, verbose)\u001b[0m\n\u001b[1;32m   1383\u001b[0m             \u001b[0moptions\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'quad'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mquad\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1384\u001b[0m         \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1385\u001b[0;31m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprec\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moptions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1386\u001b[0m         \u001b[0;32mexcept\u001b[0m \u001b[0mNotImplementedError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1387\u001b[0m             \u001b[0;31m# Fall back to the ordinary evalf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/evalf.pyc\u001b[0m in \u001b[0;36mevalf\u001b[0;34m(x, prec, options)\u001b[0m\n\u001b[1;32m   1276\u001b[0m     \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1277\u001b[0m         \u001b[0mrf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mevalf_table\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1278\u001b[0;31m         \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mprec\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moptions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1279\u001b[0m     \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1280\u001b[0m         \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/evalf.pyc\u001b[0m in \u001b[0;36mevalf_sum\u001b[0;34m(expr, prec, options)\u001b[0m\n\u001b[1;32m   1174\u001b[0m             \u001b[0mm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mi\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mprec\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1175\u001b[0m             s, err = expr.euler_maclaurin(m=m, n=n, eps=eps,\n\u001b[0;32m-> 1176\u001b[0;31m                 eval_integral=False)\n\u001b[0m\u001b[1;32m   1177\u001b[0m             \u001b[0merr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1178\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0merr\u001b[0m \u001b[0;34m<=\u001b[0m \u001b[0meps\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/concrete/summations.pyc\u001b[0m in \u001b[0;36meuler_maclaurin\u001b[0;34m(self, m, n, eps, eval_integral)\u001b[0m\n\u001b[1;32m    597\u001b[0m                     \u001b[0;32mif\u001b[0m \u001b[0mabs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterm\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0meps\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mterm\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    598\u001b[0m                         \u001b[0;32mreturn\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mabs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterm\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 599\u001b[0;31m                     \u001b[0ms\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0mterm\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    600\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mm\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    601\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mS\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mZero\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/decorators.pyc\u001b[0m in \u001b[0;36m__sympifyit_wrapper\u001b[0;34m(a, b)\u001b[0m\n\u001b[1;32m     75\u001b[0m                 \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'_op_priority'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     76\u001b[0m                     \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msympify\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstrict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 77\u001b[0;31m                 \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     78\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mSympifyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     79\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0mretval\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/numbers.pyc\u001b[0m in \u001b[0;36m__add__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m   1372\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0m__add__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1373\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mRational\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1374\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mRational\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mq\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1375\u001b[0m         \u001b[0;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mFloat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1376\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0mother\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/cache.pyc\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m     91\u001b[0m             \u001b[0;32mdef\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     92\u001b[0m                 \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 93\u001b[0;31m                     \u001b[0mretval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     94\u001b[0m                 \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     95\u001b[0m                     \u001b[0mretval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/compatibility.pyc\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwds)\u001b[0m\n\u001b[1;32m    897\u001b[0m                         \u001b[0mstats\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mHITS\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    898\u001b[0m                         \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 899\u001b[0;31m                 \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0muser_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    900\u001b[0m                 \u001b[0;32mwith\u001b[0m \u001b[0mlock\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    901\u001b[0m                     \u001b[0mroot\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnonlocal_root\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/numbers.pyc\u001b[0m in \u001b[0;36m__new__\u001b[0;34m(cls, p, q)\u001b[0m\n\u001b[1;32m   1287\u001b[0m             \u001b[0mq\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1288\u001b[0m             \u001b[0mp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1289\u001b[0;31m         \u001b[0mn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0migcd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mabs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1290\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mn\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1291\u001b[0m             \u001b[0mp\u001b[0m \u001b[0;34m//=\u001b[0m \u001b[0mn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/numbers.pyc\u001b[0m in \u001b[0;36migcd\u001b[0;34m(*args)\u001b[0m\n\u001b[1;32m    168\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    169\u001b[0m                 \u001b[0;32mwhile\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 170\u001b[0;31m                     \u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    171\u001b[0m             \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    172\u001b[0m                 \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mabs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "eq1 = expectedUnionFP.subs(a, 40).subs(n, 4000).subs(theta, 15).subs(s, 30)\n",
    "display(eq1)\n",
    "\n",
    "for num_patterns in range(100):\n",
    "    eq2 = eq1.subs(m, num_patterns)\n",
    "    #display(eq2)\n",
    "    error_prob = eq2.evalf(100)\n",
    "    print num_patterns, error_prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 1.000000000 0\n",
      "1 0.9900000000 0.01000000000\n",
      "2 0.9801000000 0.01990000000\n",
      "3 0.9702990000 0.02970100000\n",
      "4 0.9605960100 0.03940399000\n",
      "5 0.9509900499 0.04900995010\n",
      "6 0.9414801494 0.05851985060\n",
      "7 0.9320653479 0.06793465209\n",
      "8 0.9227446944 0.07725530557\n",
      "9 0.9135172475 0.08648275251\n",
      "10 0.9043820750 0.09561792499\n",
      "11 0.8953382543 0.1046617457\n",
      "12 0.8863848717 0.1136151283\n",
      "13 0.8775210230 0.1224789770\n",
      "14 0.8687458128 0.1312541872\n",
      "15 0.8600583546 0.1399416454\n",
      "16 0.8514577711 0.1485422289\n",
      "17 0.8429431934 0.1570568066\n",
      "18 0.8345137615 0.1654862385\n",
      "19 0.8261686238 0.1738313762\n",
      "20 0.8179069376 0.1820930624\n",
      "21 0.8097278682 0.1902721318\n",
      "22 0.8016305895 0.1983694105\n",
      "23 0.7936142836 0.2063857164\n",
      "24 0.7856781408 0.2143218592\n",
      "25 0.7778213594 0.2221786406\n",
      "26 0.7700431458 0.2299568542\n",
      "27 0.7623427143 0.2376572857\n",
      "28 0.7547192872 0.2452807128\n",
      "29 0.7471720943 0.2528279057\n",
      "30 0.7397003734 0.2602996266\n",
      "31 0.7323033697 0.2676966303\n",
      "32 0.7249803360 0.2750196640\n",
      "33 0.7177305326 0.2822694674\n",
      "34 0.7105532273 0.2894467727\n",
      "35 0.7034476950 0.2965523050\n",
      "36 0.6964132181 0.3035867819\n",
      "37 0.6894490859 0.3105509141\n",
      "38 0.6825545950 0.3174454050\n",
      "39 0.6757290491 0.3242709509\n",
      "40 0.6689717586 0.3310282414\n",
      "41 0.6622820410 0.3377179590\n",
      "42 0.6556592206 0.3443407794\n",
      "43 0.6491026284 0.3508973716\n",
      "44 0.6426116021 0.3573883979\n",
      "45 0.6361854861 0.3638145139\n",
      "46 0.6298236312 0.3701763688\n",
      "47 0.6235253949 0.3764746051\n",
      "48 0.6172901409 0.3827098591\n",
      "49 0.6111172395 0.3888827605\n",
      "50 0.6050060671 0.3949939329\n",
      "51 0.5989560065 0.4010439935\n",
      "52 0.5929664464 0.4070335536\n",
      "53 0.5870367819 0.4129632181\n",
      "54 0.5811664141 0.4188335859\n",
      "55 0.5753547500 0.4246452500\n",
      "56 0.5696012025 0.4303987975\n",
      "57 0.5639051905 0.4360948095\n",
      "58 0.5582661385 0.4417338615\n",
      "59 0.5526834772 0.4473165228\n",
      "60 0.5471566424 0.4528433576\n",
      "61 0.5416850760 0.4583149240\n",
      "62 0.5362682252 0.4637317748\n",
      "63 0.5309055430 0.4690944570\n",
      "64 0.5255964875 0.4744035125\n",
      "65 0.5203405226 0.4796594774\n",
      "66 0.5151371174 0.4848628826\n",
      "67 0.5099857462 0.4900142538\n",
      "68 0.5048858888 0.4951141112\n",
      "69 0.4998370299 0.5001629701\n",
      "70 0.4948386596 0.5051613404\n",
      "71 0.4898902730 0.5101097270\n",
      "72 0.4849913703 0.5150086297\n",
      "73 0.4801414566 0.5198585434\n",
      "74 0.4753400420 0.5246599580\n",
      "75 0.4705866416 0.5294133584\n",
      "76 0.4658807752 0.5341192248\n",
      "77 0.4612219674 0.5387780326\n",
      "78 0.4566097477 0.5433902523\n",
      "79 0.4520436503 0.5479563497\n",
      "80 0.4475232138 0.5524767862\n",
      "81 0.4430479816 0.5569520184\n",
      "82 0.4386175018 0.5613824982\n",
      "83 0.4342313268 0.5657686732\n",
      "84 0.4298890135 0.5701109865\n",
      "85 0.4255901234 0.5744098766\n",
      "86 0.4213342222 0.5786657778\n",
      "87 0.4171208799 0.5828791201\n",
      "88 0.4129496711 0.5870503289\n",
      "89 0.4088201744 0.5911798256\n",
      "90 0.4047319727 0.5952680273\n",
      "91 0.4006846530 0.5993153470\n",
      "92 0.3966778064 0.6033221936\n",
      "93 0.3927110284 0.6072889716\n",
      "94 0.3887839181 0.6112160819\n",
      "95 0.3848960789 0.6151039211\n",
      "96 0.3810471181 0.6189528819\n",
      "97 0.3772366469 0.6227633531\n",
      "98 0.3734642805 0.6265357195\n",
      "99 0.3697296376 0.6302703624\n"
     ]
    }
   ],
   "source": [
    "eq1 = p.subs(a, 40).subs(n, 4000)\n",
    "for num_patterns in range(100):\n",
    "    expected_distinct = eq1.subs(m, num_patterns).evalf(10)\n",
    "    print (num_patterns, expected_distinct, (1 - expected_distinct))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Expected performance for first-order TMs with varying sparsity"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAT8AAAA3CAYAAAB6gk1yAAAABHNCSVQICAgIfAhkiAAADJ5JREFU\neJztnXu0FXUVxz8IeCHkXgHxbZYgvhK7YbYKtRAVFcFXttDUai1Mo8R85MrS5a0szVo+MqyMykwl\nfIVWmA8sDfJRpC21lfjC0PIKeBEkJIPbH9+ZdebMOWfmN3N+58499+7PWrPunDm/2b99f2d+7733\ngGEYRj9kQ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      "text/plain": [
       "                          a                           \n",
       "──────────────────────────────────────────────────────\n",
       "             ⎛                            19000⋅a    ⎞\n",
       "             ⎜                            ───────    ⎟\n",
       "             ⎜                               n       ⎟\n",
       "             ⎜  ⎛    s                   ⎞           ⎟\n",
       "             ⎜  ⎜  ______                ⎟           ⎟\n",
       "             ⎜  ⎜  ╲                     ⎟           ⎟\n",
       "             ⎜  ⎜   ╲     ⎛s⎞ ⎛n - s⎞    ⎟           ⎟\n",
       "             ⎜  ⎜    ╲    ⎜ ⎟⋅⎜     ⎟    ⎟           ⎟\n",
       "             ⎜  ⎜     ╲   ⎝b⎠ ⎝a - b⎠    ⎟           ⎟\n",
       "             ⎜  ⎜      ╲  ───────────    ⎟           ⎟\n",
       "a + (-a + n)⋅⎜- ⎜-     ╱      ⎛n⎞     + 1⎟        + 1⎟\n",
       "             ⎜  ⎜     ╱       ⎜ ⎟        ⎟           ⎟\n",
       "             ⎜  ⎜    ╱        ⎝a⎠        ⎟           ⎟\n",
       "             ⎜  ⎜   ╱                    ⎟           ⎟\n",
       "             ⎜  ⎜  ╱                     ⎟           ⎟\n",
       "             ⎜  ⎜  ‾‾‾‾‾‾                ⎟           ⎟\n",
       "             ⎝  ⎝  b = θ                 ⎠           ⎠"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWYAAABDCAYAAACvMK8nAAAABHNCSVQICAgIfAhkiAAAECNJREFU\neJztnXv0FVUVxz88BAn5AYICgoGKhK9lRmVaKJpAK8VlJvawDMPMR6b4irIHluYjtaeVZuXKR/mq\nrGWuNAofZZCWpVgWGZlSgPgCEjT89cd3Zs3cuWfmzsyduffO/e3PWnfdmbnnd2bf85u7zz777LMP\nGIZhGB3FgHYLYBg5ORaYA0wBZgD3O8pcBvwXeKJ1YhmGYfRN5gEXeceTgJeA0ZEyBwKrkdI2DMMw\nSmQQsBaYGLq2c6TMcOCjwBJMMRsVpH+7BTCMjOyHrO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AABJRU5ErkJggg==\n",
      "text/plain": [
       "                            64                            \n",
       "──────────────────────────────────────────────────────────\n",
       "         ⎛                               1216000    ⎞     \n",
       "         ⎜                               ───────    ⎟     \n",
       "         ⎜                                  n       ⎟     \n",
       "         ⎜  ⎛    25                     ⎞           ⎟     \n",
       "         ⎜  ⎜  ______                   ⎟           ⎟     \n",
       "         ⎜  ⎜  ╲                        ⎟           ⎟     \n",
       "         ⎜  ⎜   ╲     ⎛25⎞ ⎛ n - 25⎞    ⎟           ⎟     \n",
       "         ⎜  ⎜    ╲    ⎜  ⎟⋅⎜       ⎟    ⎟           ⎟     \n",
       "         ⎜  ⎜     ╲   ⎝b ⎠ ⎝-b + 64⎠    ⎟           ⎟     \n",
       "         ⎜  ⎜      ╲  ──────────────    ⎟           ⎟     \n",
       "(n - 64)⋅⎜- ⎜-     ╱       ⎛n ⎞      + 1⎟        + 1⎟ + 64\n",
       "         ⎜  ⎜     ╱        ⎜  ⎟         ⎟           ⎟     \n",
       "         ⎜  ⎜    ╱         ⎝64⎠         ⎟           ⎟     \n",
       "         ⎜  ⎜   ╱                       ⎟           ⎟     \n",
       "         ⎜  ⎜  ╱                        ⎟           ⎟     \n",
       "         ⎜  ⎜  ‾‾‾‾‾‾                   ⎟           ⎟     \n",
       "         ⎝  ⎝  b = 10                   ⎠           ⎠     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\n",
      "300 0.2133333333 4053.33333333333 1.00000000000000\n",
      "400 0.1600638971 3040.00000000000 0.999524764597103\n",
      "500 0.1888256286 2432.00000000000 0.630589545802401\n",
      "600 0.4262461218 2026.66666666667 0.160723868815488\n",
      "700 0.7258061642 1737.14285714286 0.0380154287753211\n",
      "800 0.8951305190 1520.00000000000 0.0101874364838613\n",
      "900 0.9609518686 1351.11111111111 0.00311080162482483\n",
      "1000 0.9846976836 1216.00000000000 0.00106257204324782\n",
      "1100 0.9935867156 1105.45454545455 0.000398744719297588\n",
      "1200 0.9971328657 1013.33333333333 0.000161993146411579\n",
      "1300 0.9986419067 935.384615384615 7.04176141864219e-5\n",
      "1400 0.9993231120 868.571428571429 3.24477365229332e-5\n",
      "1500 0.9996471912 810.666666666667 1.57296170224554e-5\n",
      "1600 0.9998086985 760.000000000000 7.97242199767715e-6\n",
      "1700 0.9998925696 715.294117647059 4.20310689761942e-6\n",
      "1800 0.9999377508 675.555555555556 2.29504468162097e-6\n",
      "1900 0.9999629020 640.000000000000 1.29322365878282e-6\n",
      "2000 0.9999773229 608.000000000000 7.49672456579212e-7\n",
      "2100 0.9999858153 579.047619047619 4.45889875695127e-7\n",
      "2200 0.9999909394 552.727272727273 2.71481298138744e-7\n",
      "2300 0.9999941004 528.695652173913 1.68863354280829e-7\n",
      "2400 0.9999960903 506.666666666667 1.07114617319835e-7\n",
      "2500 0.9999973667 486.400000000000 6.91839375383425e-8\n",
      "2600 0.9999981996 467.692307692308 4.54367594173651e-8\n",
      "2700 0.9999987518 450.370370370370 3.03056076786371e-8\n",
      "2800 0.9999991234 434.285714285714 2.05057982535601e-8\n",
      "2900 0.9999993769 419.310344827586 1.40618219377182e-8\n",
      "3000 0.9999995521 405.333333333333 9.76412284041323e-9\n",
      "3100 0.9999996746 392.258064516129 6.85968217059619e-9\n",
      "3200 0.9999997613 380.000000000000 4.87235129623575e-9\n",
      "3300 0.9999998232 368.484848484848 3.49663416869302e-9\n",
      "3400 0.9999998679 357.647058823529 2.53382779266200e-9\n",
      "3500 0.9999999005 347.428571428571 1.85301892764823e-9\n",
      "3600 0.9999999245 337.777777777778 1.36690667633440e-9\n",
      "3700 0.9999999422 328.648648648649 1.01660491325226e-9\n",
      "3800 0.9999999555 320.000000000000 7.61962852667373e-10\n",
      "3900 0.9999999655 311.794871794872 5.75323088828602e-10\n",
      "4000 0.9999999731 304.000000000000 4.37448757931150e-10\n",
      "]\n"
     ]
    }
   ],
   "source": [
    "eq1 = subsampledFpF\n",
    "expected_num_segments_per_cell = (19*1000)*a/n\n",
    "eq2 = 1 - ((1 - subsampledFpF)**expected_num_segments_per_cell)\n",
    "jaccard = a/(a + eq2*(n - a))\n",
    "display(jaccard)\n",
    "jaccard2 = jaccard.subs(a, 64).subs(theta, 10).subs(s, 25)\n",
    "display(jaccard2)\n",
    "print (\"[\")\n",
    "for i in range(300, 4100, 100):\n",
    "    eq4 = jaccard2.subs(n, i)\n",
    "    print (i, str(eq4.evalf(10)), expected_num_segments_per_cell.subs(a, 64).subs(n, i).evalf(), eq2.subs(a, 64).subs(theta, 10).subs(s, 25).subs(n, i).evalf())\n",
    "print (\"]\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
